private function fetchText() { $textId = $this->getTextId(); // If we kept data for lazy extraction, use it now... if ($this->mTextRow !== null) { $row = $this->mTextRow; $this->mTextRow = null; } else { $row = null; } // Callers doing updates will pass in READ_LATEST as usual. Since the text/blob tables // do not normally get rows changed around, set READ_LATEST_IMMUTABLE in those cases. $flags = $this->mQueryFlags; $flags |= DBAccessObjectUtils::hasFlags($flags, self::READ_LATEST) ? self::READ_LATEST_IMMUTABLE : 0; list($index, $options, $fallbackIndex, $fallbackOptions) = DBAccessObjectUtils::getDBOptions($flags); if (!$row) { // Text data is immutable; check replica DBs first. $row = wfGetDB($index)->selectRow('text', ['old_text', 'old_flags'], ['old_id' => $textId], __METHOD__, $options); } // Fallback to DB_MASTER in some cases if the row was not found if (!$row && $fallbackIndex !== null) { // Use FOR UPDATE if it was used to fetch this revision. This avoids missing the row // due to REPEATABLE-READ. Also fallback to the master if READ_LATEST is provided. $row = wfGetDB($fallbackIndex)->selectRow('text', ['old_text', 'old_flags'], ['old_id' => $textId], __METHOD__, $fallbackOptions); } if (!$row) { wfDebugLog('Revision', "No text row with ID '{$textId}' (revision {$this->getId()})."); } $text = self::getRevisionText($row); if ($row && $text === false) { wfDebugLog('Revision', "No blob for text row '{$textId}' (revision {$this->getId()})."); } return is_string($text) ? $text : false; }
/** * Load user table data, given mId has already been set. * @param integer $flags User::READ_* constant bitfield * @return bool False if the ID does not exist, true otherwise */ public function loadFromId($flags = self::READ_NORMAL) { if ($this->mId == 0) { $this->loadDefaults(); return false; } // Try cache (unless this needs data from the master DB). // NOTE: if this thread called saveSettings(), the cache was cleared. $latest = DBAccessObjectUtils::hasFlags($flags, self::READ_LATEST); if ($latest || !$this->loadFromCache()) { wfDebug("User: cache miss for user {$this->mId}\n"); // Load from DB (make sure this thread sees its own changes) if (wfGetLB()->hasOrMadeRecentMasterChanges()) { $flags |= self::READ_LATEST; } if (!$this->loadFromDatabase($flags)) { // Can't load from ID, user is anonymous return false; } $this->saveToCache(); } $this->mLoadedItems = true; $this->queryFlagsUsed = $flags; return true; }
/** * Load user table data, given mId has already been set. * @param integer $flags User::READ_* constant bitfield * @return bool False if the ID does not exist, true otherwise */ public function loadFromId($flags = self::READ_NORMAL) { if ($this->mId == 0) { // Anonymous users are not in the database (don't need cache) $this->loadDefaults(); return false; } // Try cache (unless this needs data from the master DB). // NOTE: if this thread called saveSettings(), the cache was cleared. $latest = DBAccessObjectUtils::hasFlags($flags, self::READ_LATEST); if ($latest) { if (!$this->loadFromDatabase($flags)) { // Can't load from ID return false; } } else { $this->loadFromCache(); } $this->mLoadedItems = true; $this->queryFlagsUsed = $flags; return true; }