From dbca12bf93320af9df2972b607798f18c96dcb62 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 3 Dec 2014 10:36:12 -0800 Subject: [PATCH] Stop using $wgProfileToDatabase Was not completely removed and the remaining bits were mostly broken. $wgProfiler['output'] = 'db' is the proper way. Fixes T75917 Change-Id: I36565e2372db2ed49b219cf533ec433e8111c52f --- docs/scripts.txt | 2 +- includes/installer/DatabaseUpdater.php | 25 +++++++++++++++++++ includes/installer/MysqlUpdater.php | 12 --------- includes/installer/SqliteUpdater.php | 7 ------ profileinfo.php | 6 ++--- .../includes/db/DatabaseSqliteTest.php | 15 +++++++++-- 6 files changed, 42 insertions(+), 25 deletions(-) diff --git a/docs/scripts.txt b/docs/scripts.txt index c6fa674cec..178bb157bb 100644 --- a/docs/scripts.txt +++ b/docs/scripts.txt @@ -34,7 +34,7 @@ Primary scripts: To save the profiling information in the database (required to use this script), you have to modify StartProfiler.php to use the Profiler class and not the stub profiler which is enabled by default. - You will also need to set $wgProfileToDatabase to true in LocalSettings.php + You will also need to set $wgProfiler['output'] to 'db' in LocalSettings.php to force the profiler to save the informations in the database and apply the maintenance/archives/patch-profiling.sql patch to the database. diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index dac43371a5..a5540dbb11 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -1058,6 +1058,31 @@ abstract class DatabaseUpdater { } } + /** + * Enable profiling table when it's turned on + */ + protected function doEnableProfiling() { + global $wgProfiler; + + if ( !$this->doTable( 'profiling' ) ) { + return true; + } + + $profileToDb = false; + if ( isset( $wgProfiler['output'] ) ) { + $out = $wgProfiler['output']; + if ( $out === 'db' ) { + $profileToDb = true; + } elseif( is_array( $out ) && in_array( 'db', $out ) ) { + $profileToDb = true; + } + } + + if ( $profileToDb && !$this->db->tableExists( 'profiling', __METHOD__ ) ) { + $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' ); + } + } + /** * Rebuilds the localisation cache */ diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 990b5b031e..c3dedbcbdb 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -924,18 +924,6 @@ class MysqlUpdater extends DatabaseUpdater { } } - protected function doEnableProfiling() { - global $wgProfileToDatabase; - - if ( !$this->doTable( 'profiling' ) ) { - return true; - } - - if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) { - $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' ); - } - } - protected function doMaybeProfilingMemoryUpdate() { if ( !$this->doTable( 'profiling' ) ) { return true; diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index ab5ab7d79e..91cbb04e58 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -168,11 +168,4 @@ class SqliteUpdater extends DatabaseUpdater { $this->output( "...fulltext search table appears to be in order.\n" ); } } - - protected function doEnableProfiling() { - global $wgProfileToDatabase; - if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) { - $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' ); - } - } } diff --git a/profileinfo.php b/profileinfo.php index b930f42fcf..4e3fb5ad28 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -27,7 +27,7 @@ ini_set( 'zlib.output_compression', 'off' ); -$wgEnableProfileInfo = $wgProfileToDatabase = false; +$wgEnableProfileInfo = false; require __DIR__ . '/includes/WebStart.php'; header( 'Content-Type: text/html; charset=utf-8' ); @@ -149,8 +149,8 @@ $dbr = wfGetDB( DB_SLAVE ); if ( !$dbr->tableExists( 'profiling' ) ) { echo '

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

' - . '

If you want to log profiling data, enable $wgProfileToDatabase' - . ' in your LocalSettings.php and run maintenance/update.php to' + . '

If you want to log profiling data, enable $wgProfiler[\'output\'] = \'db\'' + . ' in your StartProfiler.php and run maintenance/update.php to' . ' create the profiling table.' . ''; exit( 1 ); diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php index 98b4ca046c..588e544087 100644 --- a/tests/phpunit/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php @@ -272,7 +272,7 @@ class DatabaseSqliteTest extends MediaWikiTestCase { * @todo Currently only checks list of tables */ public function testUpgrades() { - global $IP, $wgVersion, $wgProfileToDatabase; + global $IP, $wgVersion, $wgProfiler; // Versions tested $versions = array( @@ -291,7 +291,18 @@ class DatabaseSqliteTest extends MediaWikiTestCase { $currentDB = new DatabaseSqliteStandalone( ':memory:' ); $currentDB->sourceFile( "$IP/maintenance/tables.sql" ); - if ( $wgProfileToDatabase ) { + + $profileToDb = false; + if ( isset( $wgProfiler['output'] ) ) { + $out = $wgProfiler['output']; + if ( $out === 'db' ) { + $profileToDb = true; + } elseif( is_array( $out ) && in_array( 'db', $out ) ) { + $profileToDb = true; + } + } + + if ( $profileToDb ) { $currentDB->sourceFile( "$IP/maintenance/sqlite/archives/patch-profiling.sql" ); } $currentTables = $this->getTables( $currentDB ); -- 2.20.1