/** * @return Bool|ResultWrapper */ static function loadAndLazyInit() { wfDebug( __METHOD__ . ": reading site_stats from slave\n" ); $row = self::doLoad( wfGetDB( DB_SLAVE ) ); if ( !self::isSane( $row ) ) { // Might have just been initialized during this request? Underflow? wfDebug( __METHOD__ . ": site_stats damaged or missing on slave\n" ); $row = self::doLoad( wfGetDB( DB_MASTER ) ); } if ( !self::isSane( $row ) ) { // Normally the site_stats table is initialized at install time. // Some manual construction scenarios may leave the table empty or // broken, however, for instance when importing from a dump into a // clean schema with mwdumper. wfDebug( __METHOD__ . ": initializing damaged or missing site_stats\n" ); SiteStatsInit::doAllAndCommit( wfGetDB( DB_SLAVE ) ); $row = self::doLoad( wfGetDB( DB_MASTER ) ); } if ( !self::isSane( $row ) ) { wfDebug( __METHOD__ . ": site_stats persistently nonsensical o_O\n" ); } return $row; }
/** * Check the site_stats table is not properly populated. */ protected function checkStats() { $this->output("...site_stats is populated..."); $row = $this->db->selectRow('site_stats', '*', array('ss_row_id' => 1), __METHOD__); if ($row === false) { $this->output("data is missing! rebuilding...\n"); } elseif (isset($row->site_stats) && $row->ss_total_pages == -1) { $this->output("missing ss_total_pages, rebuilding...\n"); } else { $this->output("done.\n"); return; } SiteStatsInit::doAllAndCommit($this->db); }