* @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;
exit( 1 );
}
-$dbr = wfGetDB( DB_SLAVE );
+$dbr = wfGetDB( DB_REPLICA );
if ( !$dbr->tableExists( 'profiling' ) ) {
echo '<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
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;
$this->count = $count;
$this->time = $time;
$this->memory = $memory;
- $this->children = array();
+ $this->children = [];
}
public function add_child( $child ) {
if ( !$ex ) {
if ( count( $this->children ) ) {
- $url = getEscapedProfileUrl( false, false, $expand + array( $this->name() => true ) );
+ $url = getEscapedProfileUrl( false, false, $expand + [ $this->name() => true ] );
$extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
} 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 );
<?php echo htmlspecialchars( str_replace( ',', ', ', $this->name() ) ) . $extet ?>
</div>
</th>
- <?php //@codingStandardsIgnoreStart ?>
+ <?php // phpcs:disable Generic.Files.LineLength,Generic.PHP.NoSilencedErrors ?>
<td class="mw-profileinfo-timep"><?php echo @wfPercent( $this->time() / self::$totaltime * 100 ); ?></td>
<td class="mw-profileinfo-memoryp"><?php echo @wfPercent( $this->memory() / self::$totalmemory * 100 ); ?></td>
<td class="mw-profileinfo-count"><?php echo $this->count(); ?></td>
<td class="mw-profileinfo-mpc"><?php echo round( sprintf( '%.2f', $this->memoryPerCall() / 1024 ), 2 ); ?></td>
<td class="mw-profileinfo-tpr"><?php echo @round( sprintf( '%.2f', $this->time() / self::$totalcount ), 2 ); ?></td>
<td class="mw-profileinfo-mpr"><?php echo @round( sprintf( '%.2f', $this->memory() / self::$totalcount / 1024 ), 2 ); ?></td>
- <?php //@codingStandardsIgnoreEnd ?>
+ <?php // phpcs:enable ?>
</tr>
<?php
if ( $ex ) {
}
public function timePerCall() {
- // @codingStandardsIgnoreStart
+ // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
return @( $this->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() {
};
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() );
}
}
-$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'];
$res = $dbr->select(
'profiling',
'*',
- array(),
+ [],
'profileinfo.php',
- array( 'ORDER BY' => 'pf_name ASC' )
+ [ 'ORDER BY' => 'pf_name ASC' ]
);
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;
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;
}
$points[] = $s;
- // @codingStandardsIgnoreStart
+ // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
@usort( $points, 'compare_point' );
- // @codingStandardsIgnoreEnd
foreach ( $points as $point ) {
if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) {