r72842 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72841‎ | r72842 | r72843 >
Date:09:07, 12 September 2010
Author:ialex
Status:ok (Comments)
Tags:todo 
Comment:
* Use Maintenance::runChild() to get the child script instance
* Moved do_stats_init() to DatabaseUpdater and call it from doUpdates() for consistency with purgeCache(), this inverts the order of execution with default messages deletion, but I don't think this should break anything
* Removed the early return for postgres, which was a leftover from the old do_postgres_updates() crap
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/update.php (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/update.php
@@ -59,21 +59,11 @@
6060 $updater = DatabaseUpdater::newForDb( $db, $shared );
6161 $updater->doUpdates( $purge );
6262
63 - if ( !defined( 'MW_NO_SETUP' ) ) {
64 - define( 'MW_NO_SETUP', true );
65 - }
66 -
6763 foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
68 - call_user_func_array( array( new $maint, 'execute' ), array() );
 64+ $this->runChild( $maint )->execute();
6965 }
7066
71 - if ( $db->getType() === 'postgres' ) {
72 - return;
73 - }
74 -
75 - do_stats_init();
76 -
77 - $this->output( "Done.\n" );
 67+ $this->output( "\nDone.\n" );
7868 }
7969
8070 protected function afterFinalSetup() {
Index: trunk/phase3/maintenance/updaters.inc
@@ -567,21 +567,6 @@
568568 }
569569 }
570570
571 -function do_stats_init() {
572 - // Sometimes site_stats table is not properly populated.
573 - wfOut( "\nChecking site_stats row..." );
574 - $row = wfGetDB( DB_MASTER )->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
575 - if ( $row === false ) {
576 - wfOut( "data is missing! rebuilding...\n" );
577 - } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
578 - wfOut( "missing ss_total_pages, rebuilding...\n" );
579 - } else {
580 - wfOut( "ok.\n" );
581 - return;
582 - }
583 - SiteStatsInit::doAllAndCommit( false );
584 -}
585 -
586571 function do_active_users_init() {
587572 $dbw = wfGetDB( DB_MASTER );
588573 $activeUsers = $dbw->selectField( 'site_stats', 'ss_active_users', false, __METHOD__ );
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -135,6 +135,7 @@
136136 if( $purge ) {
137137 $this->purgeCache();
138138 }
 139+ $this->checkStats();
139140 }
140141
141142 /**
@@ -376,4 +377,22 @@
377378 $this->db->delete( 'objectcache', '*', __METHOD__ );
378379 wfOut( "done.\n" );
379380 }
 381+
 382+ /**
 383+ * Check the site_stats table is not properly populated.
 384+ */
 385+ protected function checkStats() {
 386+ wfOut( "Checking site_stats row..." );
 387+ $row = $this->db->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
 388+ if ( $row === false ) {
 389+ wfOut( "data is missing! rebuilding...\n" );
 390+ } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
 391+ wfOut( "missing ss_total_pages, rebuilding...\n" );
 392+ } else {
 393+ wfOut( "done.\n" );
 394+ return;
 395+ }
 396+ SiteStatsInit::doAllAndCommit( false );
 397+ }
 398+
380399 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r91076Per Platonides, follow-up r72842: pass the db connection to SiteStatsInit::do...ialex15:39, 29 June 2011

Comments

#Comment by Platonides (talk | contribs)   14:28, 29 June 2011

SiteStatsInit uses its own db connection instead of $this->db

Status & tagging log