if ( $this->fld_ids ) {
$vals['pageid'] = (int)$row->rev_page;
$vals['revid'] = (int)$row->rev_id;
- // $vals['textid'] = (int)$row->rev_text_id; // todo: Should this field be exposed?
if ( !is_null( $row->rev_parent_id ) ) {
$vals['parentid'] = (int)$row->rev_parent_id;
/**
* Process cache of loaded messages that are defined in MediaWiki namespace
*
- * @var MapCacheLRU Map of (language code => key => " <MESSAGE>" or "!TOO BIG")
+ * @var MapCacheLRU Map of (language code => key => " <MESSAGE>" or "!TOO BIG" or "!ERROR")
*/
protected $cache;
}
// Set the text for small software-defined messages in the main cache map
+ $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+ $revQuery = $revisionStore->getQueryInfo( [ 'page', 'user' ] );
$res = $dbr->select(
- [ 'page', 'revision', 'text' ],
- [ 'page_title', 'page_latest', 'old_id', 'old_text', 'old_flags' ],
+ $revQuery['tables'],
+ $revQuery['fields'],
array_merge( $conds, [ 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize ) ] ),
__METHOD__ . "($code)-small",
[],
- [
- 'revision' => [ 'JOIN', 'page_latest=rev_id' ],
- 'text' => [ 'JOIN', 'rev_text_id=old_id' ],
- ]
+ $revQuery['joins']
);
foreach ( $res as $row ) {
$name = $this->contLang->lcfirst( $row->page_title );
// Include entries/stubs for all keys in $mostused in adaptive mode
if ( $wgAdaptiveMessageCache || $this->isMainCacheable( $name, $overridable ) ) {
- $text = Revision::getRevisionText( $row );
- if ( $text === false ) {
- // Failed to fetch data; possible ES errors?
- // Store a marker to fetch on-demand as a workaround...
- // TODO Use a differnt marker
- $entry = '!TOO BIG';
+ try {
+ $rev = $revisionStore->newRevisionFromRow( $row );
+ $content = $rev->getContent( MediaWiki\Revision\SlotRecord::MAIN );
+ $text = $this->getMessageTextFromContent( $content );
+ } catch ( Exception $ex ) {
+ $text = false;
+ }
+
+ if ( !is_string( $text ) ) {
+ $entry = '!ERROR';
wfDebugLog(
'MessageCache',
__METHOD__
if ( $entry !== null ) {
// Message page exists as an override of a software messages
if ( substr( $entry, 0, 1 ) === ' ' ) {
- // The message exists and is not '!TOO BIG'
+ // The message exists and is not '!TOO BIG' or '!ERROR'
return (string)substr( $entry, 1 );
} elseif ( $entry === '!NONEXISTENT' ) {
// The text might be '-' or missing due to some data loss
* @author Rob Church <robchur@gmail.com>
*/
public function purgeRedundantText( $delete = true ) {
+ global $wgMultiContentRevisionSchemaMigrationStage;
+
# Data should come off the master, wrapped in a transaction
$dbw = $this->getDB( DB_MASTER );
$this->beginTransaction( $dbw, __METHOD__ );
- # Get "active" text records from the revisions table
- $cur = [];
- $this->output( 'Searching for active text records in revisions table...' );
- $res = $dbw->select( 'revision', 'rev_text_id', [], __METHOD__, [ 'DISTINCT' ] );
- foreach ( $res as $row ) {
- $cur[] = $row->rev_text_id;
- }
- $this->output( "done.\n" );
+ if ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) {
+ # Get "active" text records from the revisions table
+ $cur = [];
+ $this->output( 'Searching for active text records in revisions table...' );
+ $res = $dbw->select( 'revision', 'rev_text_id', [], __METHOD__, [ 'DISTINCT' ] );
+ foreach ( $res as $row ) {
+ $cur[] = $row->rev_text_id;
+ }
+ $this->output( "done.\n" );
- # Get "active" text records from the archive table
- $this->output( 'Searching for active text records in archive table...' );
- $res = $dbw->select( 'archive', 'ar_text_id', [], __METHOD__, [ 'DISTINCT' ] );
- foreach ( $res as $row ) {
- # old pre-MW 1.5 records can have null ar_text_id's.
- if ( $row->ar_text_id !== null ) {
- $cur[] = $row->ar_text_id;
+ # Get "active" text records from the archive table
+ $this->output( 'Searching for active text records in archive table...' );
+ $res = $dbw->select( 'archive', 'ar_text_id', [], __METHOD__, [ 'DISTINCT' ] );
+ foreach ( $res as $row ) {
+ # old pre-MW 1.5 records can have null ar_text_id's.
+ if ( $row->ar_text_id !== null ) {
+ $cur[] = $row->ar_text_id;
+ }
+ }
+ $this->output( "done.\n" );
+ } else {
+ # Get "active" text records via the content table
+ $cur = [];
+ $this->output( 'Searching for active text records via contents table...' );
+ $res = $dbw->select( 'content', 'content_address', [], __METHOD__, [ 'DISTINCT' ] );
+ $blobStore = MediaWikiServices::getInstance()->getBlobStore();
+ foreach ( $res as $row ) {
+ $textId = $blobStore->getTextIdFromAddress( $row->content_address );
+ if ( $textId ) {
+ $cur[] = $textId;
+ }
}
+ $this->output( "done.\n" );
}
$this->output( "done.\n" );
$startOption = 'start-archive';
}
+ if ( !$this->dbw->fieldExists( $table, $fields['text_id'], __METHOD__ ) ) {
+ $this->writeln( "No need to populate, $table.{$fields['text_id']} field does not exist" );
+ return;
+ }
+
$minmax = $this->dbw->selectRow(
$table,
[ 'min' => "MIN( $idField )", 'max' => "MAX( $idField )" ],
$this->output( "Rebuilding index fields for {$count} pages...\n" );
$n = 0;
- $revQuery = Revision::getQueryInfo( [ 'page', 'text' ] );
+ $revQuery = Revision::getQueryInfo( [ 'page' ] );
while ( $n < $count ) {
if ( $n ) {
$res = $this->db->select(
$revQuery['tables'],
$revQuery['fields'],
- [ "page_id BETWEEN $n AND $end", 'page_latest = rev_id', 'rev_text_id = old_id' ],
+ [ "page_id BETWEEN $n AND $end", 'page_latest = rev_id' ],
__METHOD__,
[],
$revQuery['joins']
] ],
'revision' => [ 'revision', 'rev_user', 'rev_id', [
'rev_page' => 42,
- 'rev_text_id' => 42,
'rev_len' => 0,
'rev_timestamp' => $db->timestamp(),
] ],
$m->getInsertValuesWithTempTable( $this->db, 'rev_user', $userIdentity );
$extraFields = [
'rev_page' => 42,
- 'rev_text_id' => 42,
'rev_len' => 0,
'rev_timestamp' => $this->db->timestamp(),
] + $cFields;