X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=profileinfo.php;h=ca8c1bbbfa51da722eb5559561f0a7e72ec87b99;hp=f44ee5a231fea0e7b4c6f979e4bfcbbecd7086ff;hb=d135b6ebe5a79a6b3d0e03fe2bd11747b971ff68;hpb=cb2896f90ebef77c02c9da4067b0e56e37471092 diff --git a/profileinfo.php b/profileinfo.php index f44ee5a231..ca8c1bbbfa 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -25,6 +25,11 @@ * @file */ +// This endpoint is supposed to be independent of request cookies and other +// details of the session. Log warnings for violations of the no-session +// constraint. +define( 'MW_NO_SESSION', 'warn' ); + ini_set( 'zlib.output_compression', 'off' ); $wgEnableProfileInfo = false; @@ -145,7 +150,7 @@ if ( !$wgEnableProfileInfo ) { exit( 1 ); } -$dbr = wfGetDB( DB_SLAVE ); +$dbr = wfGetDB( DB_REPLICA ); if ( !$dbr->tableExists( 'profiling' ) ) { echo '

No profiling table exists, so we can\'t show you anything.

' @@ -156,16 +161,15 @@ if ( !$dbr->tableExists( 'profiling' ) ) { exit( 1 ); } -$expand = array(); +$expand = []; if ( isset( $_REQUEST['expand'] ) ) { foreach ( explode( ',', $_REQUEST['expand'] ) as $f ) { $expand[$f] = true; } } -// @codingStandardsIgnoreStart +// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps class profile_point { - // @codingStandardsIgnoreEnd public $name; public $count; @@ -179,7 +183,7 @@ class profile_point { $this->count = $count; $this->time = $time; $this->memory = $memory; - $this->children = array(); + $this->children = []; } public function add_child( $child ) { @@ -195,16 +199,16 @@ class profile_point { if ( !$ex ) { if ( count( $this->children ) ) { - $url = getEscapedProfileUrl( false, false, $expand + array( $this->name() => true ) ); + $url = getEscapedProfileUrl( false, false, $expand + [ $this->name() => true ] ); $extet = " [+]"; } else { $extet = ''; } } else { - $e = array(); + $e = []; foreach ( $expand as $name => $ep ) { if ( $name != $this->name() ) { - $e += array( $name => $ep ); + $e += [ $name => $ep ]; } } $url = getEscapedProfileUrl( false, false, $e ); @@ -217,7 +221,7 @@ class profile_point { name() ) ) . $extet ?> - + time() / self::$totaltime * 100 ); ?> memory() / self::$totalmemory * 100 ); ?> count(); ?> @@ -226,7 +230,7 @@ class profile_point { memoryPerCall() / 1024 ), 2 ); ?> time() / self::$totalcount ), 2 ); ?> memory() / self::$totalcount / 1024 ), 2 ); ?> - + time / $this->count ); - // @codingStandardsIgnoreEnd } public function memoryPerCall() { - // @codingStandardsIgnoreStart + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged return @( $this->memory / $this->count ); - // @codingStandardsIgnoreEnd } public function callsPerRequest() { - // @codingStandardsIgnoreStart + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged return @( $this->count / self::$totalcount ); - // @codingStandardsIgnoreEnd } public function timePerRequest() { - // @codingStandardsIgnoreStart + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged return @( $this->time / self::$totalcount ); - // @codingStandardsIgnoreEnd } public function memoryPerRequest() { - // @codingStandardsIgnoreStart + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged return @( $this->memory / self::$totalcount ); - // @codingStandardsIgnoreEnd } public function fmttime() { @@ -288,9 +287,9 @@ class profile_point { }; function compare_point( profile_point $a, profile_point $b ) { - // @codingStandardsIgnoreStart + // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $sort; - // @codingStandardsIgnoreEnd + switch ( $sort ) { case 'name': return strcmp( $a->name(), $b->name() ); @@ -313,8 +312,8 @@ function compare_point( profile_point $a, profile_point $b ) { } } -$sorts = array( 'time', 'memory', 'count', 'calls_per_req', 'name', - 'time_per_call', 'memory_per_call', 'time_per_req', 'memory_per_req' ); +$sorts = [ 'time', 'memory', 'count', 'calls_per_req', 'name', + 'time_per_call', 'memory_per_call', 'time_per_req', 'memory_per_req' ]; $sort = 'time'; if ( isset( $_REQUEST['sort'] ) && in_array( $_REQUEST['sort'], $sorts ) ) { $sort = $_REQUEST['sort']; @@ -323,9 +322,9 @@ if ( isset( $_REQUEST['sort'] ) && in_array( $_REQUEST['sort'], $sorts ) ) { $res = $dbr->select( 'profiling', '*', - array(), + [], 'profileinfo.php', - array( 'ORDER BY' => 'pf_name ASC' ) + [ 'ORDER BY' => 'pf_name ASC' ] ); if ( isset( $_REQUEST['filter'] ) ) { @@ -385,9 +384,8 @@ if ( isset( $_REQUEST['filter'] ) ) { profile_point::$totalmemory = 0.0; function getEscapedProfileUrl( $_filter = false, $_sort = false, $_expand = false ) { - // @codingStandardsIgnoreStart + // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $filter, $sort, $expand; - // @codingStandardsIgnoreEnd if ( $_expand === false ) { $_expand = $expand; @@ -395,16 +393,16 @@ if ( isset( $_REQUEST['filter'] ) ) { return htmlspecialchars( '?' . - wfArrayToCgi( array( + wfArrayToCgi( [ 'filter' => $_filter ? $_filter : $filter, 'sort' => $_sort ? $_sort : $sort, 'expand' => implode( ',', array_keys( $_expand ) ) - ) ) + ] ) ); } - $points = array(); - $queries = array(); + $points = []; + $queries = []; $sqltotal = 0.0; $last = false; @@ -436,7 +434,8 @@ if ( isset( $_REQUEST['filter'] ) ) { } $points[] = $s; - usort( $points, 'compare_point' ); + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + @usort( $points, 'compare_point' ); foreach ( $points as $point ) { if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) {