update.php now create profiling table when needed
When enabling $wgProfileToDatabase, one would have to manually apply a patch to the database that would add the `profiling` table. This patch let update.php creates the table whenever $wgProfileToDatabase is true. This also provide a SQL patch for SQLite backend and update profileinfo.php to give some clue about enabling the global and running update.php Change-Id: If68a25f7ec2b0fbb61f82a318427abe58a89dae7
This commit is contained in:
parent
56831e1f9e
commit
4fbaa0b822
5 changed files with 34 additions and 4 deletions
|
|
@ -4591,7 +4591,9 @@ $wgProfileOnly = false;
|
|||
* Log sums from profiling into "profiling" table in db.
|
||||
*
|
||||
* You have to create a 'profiling' table in your database before using
|
||||
* this feature, see maintenance/archives/patch-profiling.sql
|
||||
* this feature. Run set $wgProfileToDatabase to true in
|
||||
* LocalSettings.php and run maintenance/update.php or otherwise
|
||||
* manually add patch-profiling.sql to your database.
|
||||
*
|
||||
* To enable profiling, edit StartProfiler.php
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ class MysqlUpdater extends DatabaseUpdater {
|
|||
array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
|
||||
array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
|
||||
array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
|
||||
array( 'doEnableProfiling' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -772,6 +773,13 @@ class MysqlUpdater extends DatabaseUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
protected function doEnableProfiling() {
|
||||
global $wgProfileToDatabase;
|
||||
if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) {
|
||||
$this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
|
||||
}
|
||||
}
|
||||
|
||||
protected function doMaybeProfilingMemoryUpdate() {
|
||||
if ( !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
|
||||
// Simply ignore
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ class SqliteUpdater extends DatabaseUpdater {
|
|||
array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
|
||||
array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
|
||||
array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
|
||||
array( 'doEnableProfiling' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -129,4 +130,11 @@ 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' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
maintenance/sqlite/archives/patch-profiling.sql
Normal file
12
maintenance/sqlite/archives/patch-profiling.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- profiling table
|
||||
-- This is optional
|
||||
|
||||
CREATE TABLE /*_*/profiling (
|
||||
pf_count int NOT NULL default 0,
|
||||
pf_time float NOT NULL default 0,
|
||||
pf_memory float NOT NULL default 0,
|
||||
pf_name varchar(255) NOT NULL default '',
|
||||
pf_server varchar(30) NOT NULL default ''
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX /*i*/pf_name_server ON /*_*/profiling (pf_name, pf_server);
|
||||
|
|
@ -156,9 +156,9 @@ $dbr = wfGetDB( DB_SLAVE );
|
|||
|
||||
if( !$dbr->tableExists( 'profiling' ) ) {
|
||||
echo '<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
|
||||
. '<p>If you want to log profiling data, create the table using '
|
||||
. '<code>maintenance/archives/patch-profiling.sql</code> and enable '
|
||||
. '<code>$wgProfileToDatabase</code>.</p>'
|
||||
. '<p>If you want to log profiling data, enable <code>$wgProfileToDatabase</code>'
|
||||
. ' in your LocalSettings.php and run <code>maintenance/update.php</code> to'
|
||||
. ' create the profiling table.'
|
||||
. '</body></html>';
|
||||
exit( 1 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue