MediaWiki  master
XmlDumpWriter.php
Go to the documentation of this file.
1 <?php
33 use Wikimedia\Assert\Assert;
34 use Wikimedia\IPUtils;
35 
40 
42  public const WRITE_CONTENT = 0;
43 
45  public const WRITE_STUB = 1;
46 
51  private const WRITE_STUB_DELETED = 2;
52 
57  public static $supportedSchemas = [
60  ];
61 
67  private $schemaVersion;
68 
74  private $currentTitle = null;
75 
79  private $contentMode;
80 
82  private $hookRunner;
83 
90  public function __construct(
91  $contentMode = self::WRITE_CONTENT,
93  ) {
94  Assert::parameter(
95  in_array( $contentMode, [ self::WRITE_CONTENT, self::WRITE_STUB ] ),
96  '$contentMode',
97  'must be one of the following constants: WRITE_CONTENT or WRITE_STUB.'
98  );
99 
100  Assert::parameter(
101  in_array( $schemaVersion, self::$supportedSchemas ),
102  '$schemaVersion',
103  'must be one of the following schema versions: '
104  . implode( ',', self::$supportedSchemas )
105  );
106 
107  $this->contentMode = $contentMode;
108  $this->schemaVersion = $schemaVersion;
109  $this->hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
110  }
111 
122  public function openStream() {
123  $ver = $this->schemaVersion;
124  return Xml::element( 'mediawiki', [
125  'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
126  'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
127  /*
128  * When a new version of the schema is created, it needs staging on mediawiki.org.
129  * This requires a change in the operations/mediawiki-config git repo.
130  *
131  * Create a changeset like https://gerrit.wikimedia.org/r/#/c/149643/ in which
132  * you copy in the new xsd file.
133  *
134  * After it is reviewed, merged and deployed (sync-docroot), the index.html needs purging.
135  * echo "https://www.mediawiki.org/xml/index.html" | mwscript purgeList.php --wiki=aawiki
136  */
137  'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
138  "http://www.mediawiki.org/xml/export-$ver.xsd",
139  'version' => $ver,
140  'xml:lang' => MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() ],
141  null ) .
142  "\n" .
143  $this->siteInfo();
144  }
145 
149  private function siteInfo() {
150  $info = [
151  $this->sitename(),
152  $this->dbname(),
153  $this->homelink(),
154  $this->generator(),
155  $this->caseSetting(),
156  $this->namespaces() ];
157  return " <siteinfo>\n " .
158  implode( "\n ", $info ) .
159  "\n </siteinfo>\n";
160  }
161 
165  private function sitename() {
166  $sitename = MediaWikiServices::getInstance()->getMainConfig()->get( 'Sitename' );
167  return Xml::element( 'sitename', [], $sitename );
168  }
169 
173  private function dbname() {
174  $dbname = MediaWikiServices::getInstance()->getMainConfig()->get( 'DBname' );
175  return Xml::element( 'dbname', [], $dbname );
176  }
177 
181  private function generator() {
182  return Xml::element( 'generator', [], 'MediaWiki ' . MW_VERSION );
183  }
184 
188  private function homelink() {
189  return Xml::element( 'base', [], Title::newMainPage()->getCanonicalURL() );
190  }
191 
195  private function caseSetting() {
196  $capitalLinks = MediaWikiServices::getInstance()->getMainConfig()->get( 'CapitalLinks' );
197  // "case-insensitive" option is reserved for future
198  $sensitivity = $capitalLinks ? 'first-letter' : 'case-sensitive';
199  return Xml::element( 'case', [], $sensitivity );
200  }
201 
205  private function namespaces() {
206  $spaces = "<namespaces>\n";
207  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
208  foreach (
209  MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
210  as $ns => $title
211  ) {
212  $spaces .= ' ' .
213  Xml::element( 'namespace',
214  [
215  'key' => $ns,
216  'case' => $nsInfo->isCapitalized( $ns )
217  ? 'first-letter' : 'case-sensitive',
218  ], $title ) . "\n";
219  }
220  $spaces .= " </namespaces>";
221  return $spaces;
222  }
223 
230  public function closeStream() {
231  return "</mediawiki>\n";
232  }
233 
241  public function openPage( $row ) {
242  $out = " <page>\n";
243  $this->currentTitle = Title::newFromRow( $row );
244  $canonicalTitle = self::canonicalTitle( $this->currentTitle );
245  $out .= ' ' . Xml::elementClean( 'title', [], $canonicalTitle ) . "\n";
246  $out .= ' ' . Xml::element( 'ns', [], strval( $row->page_namespace ) ) . "\n";
247  $out .= ' ' . Xml::element( 'id', [], strval( $row->page_id ) ) . "\n";
248  if ( $row->page_is_redirect ) {
249  $services = MediaWikiServices::getInstance();
250  $page = $services->getWikiPageFactory()->newFromTitle( $this->currentTitle );
251  $redirectStore = $services->getRedirectStore();
252  $redirect = $this->invokeLenient(
253  static function () use ( $page, $redirectStore ) {
254  return $redirectStore->getRedirectTarget( $page );
255  },
256  'Failed to get redirect target of page ' . $page->getId()
257  );
258  if ( $redirect instanceof Title && $redirect->isValidRedirectTarget() ) {
259  $out .= ' ';
260  $out .= Xml::element( 'redirect', [ 'title' => self::canonicalTitle( $redirect ) ] );
261  $out .= "\n";
262  }
263  }
264 
265  if ( $row->page_restrictions != '' ) {
266  $out .= ' ' . Xml::element( 'restrictions', [],
267  strval( $row->page_restrictions ) ) . "\n";
268  }
269 
270  $this->hookRunner->onXmlDumpWriterOpenPage( $this, $out, $row, $this->currentTitle );
271 
272  return $out;
273  }
274 
281  public function closePage() {
282  if ( $this->currentTitle !== null ) {
283  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
284  // In rare cases, link cache has the same key for some pages which
285  // might be read as part of the same batch. T220424 and T220316
286  $linkCache->clearLink( $this->currentTitle );
287  }
288  return " </page>\n";
289  }
290 
294  private function getRevisionStore() {
295  return MediaWikiServices::getInstance()->getRevisionStore();
296  }
297 
301  private function getBlobStore() {
302  // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
303  return MediaWikiServices::getInstance()->getBlobStore();
304  }
305 
317  private function invokeLenient( $callback, $warning ) {
318  try {
319  return $callback();
320  } catch ( SuppressedDataException $ex ) {
321  return null;
322  } catch ( Exception $ex ) {
323  if ( $ex instanceof MWException || $ex instanceof RuntimeException ||
324  $ex instanceof InvalidArgumentException ) {
325  MWDebug::warning( $warning . ': ' . $ex->getMessage() );
326  return null;
327  } else {
328  throw $ex;
329  }
330  }
331  }
332 
344  public function writeRevision( $row, $slotRows = null ) {
345  $rev = $this->getRevisionStore()->newRevisionFromRowAndSlots(
346  $row,
347  $slotRows,
348  0,
349  $this->currentTitle
350  );
351 
352  $out = " <revision>\n";
353  $out .= " " . Xml::element( 'id', null, strval( $rev->getId() ) ) . "\n";
354 
355  if ( $rev->getParentId() ) {
356  $out .= " " . Xml::element( 'parentid', null, strval( $rev->getParentId() ) ) . "\n";
357  }
358 
359  $out .= $this->writeTimestamp( $rev->getTimestamp() );
360 
361  if ( $rev->isDeleted( RevisionRecord::DELETED_USER ) ) {
362  $out .= " " . Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
363  } else {
364  // empty values get written out as uid 0, see T224221
365  $user = $rev->getUser();
366  $out .= $this->writeContributor(
367  $user ? $user->getId() : 0,
368  $user ? $user->getName() : ''
369  );
370  }
371 
372  if ( $rev->isMinor() ) {
373  $out .= " <minor/>\n";
374  }
375  if ( $rev->isDeleted( RevisionRecord::DELETED_COMMENT ) ) {
376  $out .= " " . Xml::element( 'comment', [ 'deleted' => 'deleted' ] ) . "\n";
377  } else {
378  if ( $rev->getComment()->text != '' ) {
379  $out .= " "
380  // @phan-suppress-next-line SecurityCheck-DoubleEscaped getComment is polluted by truncate
381  . Xml::elementClean( 'comment', [], strval( $rev->getComment()->text ) )
382  . "\n";
383  }
384  }
385 
386  $contentMode = $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ? self::WRITE_STUB_DELETED
388 
389  $slots = $rev->getSlots()->getSlots();
390 
391  // use predictable order, put main slot first
392  ksort( $slots );
393  $out .= $this->writeSlot( $slots[SlotRecord::MAIN], $contentMode );
394 
395  foreach ( $slots as $role => $slot ) {
396  if ( $role === SlotRecord::MAIN ) {
397  continue;
398  }
399  $out .= $this->writeSlot( $slot, $contentMode );
400  }
401 
402  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
403  $out .= " <sha1/>\n";
404  } else {
405  $sha1 = $this->invokeLenient(
406  static function () use ( $rev ) {
407  return $rev->getSha1();
408  },
409  'failed to determine sha1 for revision ' . $rev->getId()
410  );
411  $out .= " " . Xml::element( 'sha1', null, strval( $sha1 ) ) . "\n";
412  }
413 
414  // Avoid PHP 7.1 warning from passing $this by reference
415  $writer = $this;
416  $text = '';
417  if ( $contentMode === self::WRITE_CONTENT ) {
419  $content = $this->invokeLenient(
420  static function () use ( $rev ) {
421  return $rev->getContent( SlotRecord::MAIN, RevisionRecord::RAW );
422  },
423  'Failed to load main slot content of revision ' . $rev->getId()
424  );
425 
426  $text = $content ? $content->serialize() : '';
427  }
428  $this->hookRunner->onXmlDumpWriterWriteRevision( $writer, $out, $row, $text, $rev );
429 
430  $out .= " </revision>\n";
431 
432  return $out;
433  }
434 
441  private function writeSlot( SlotRecord $slot, $contentMode ) {
442  $isMain = $slot->getRole() === SlotRecord::MAIN;
443  $isV11 = $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11;
444 
445  if ( !$isV11 && !$isMain ) {
446  // ignore extra slots
447  return '';
448  }
449 
450  $out = '';
451  $indent = ' ';
452 
453  if ( !$isMain ) {
454  // non-main slots are wrapped into an additional element.
455  $out .= ' ' . Xml::openElement( 'content' ) . "\n";
456  $indent .= ' ';
457  $out .= $indent . Xml::element( 'role', null, strval( $slot->getRole() ) ) . "\n";
458  }
459 
460  if ( $isV11 ) {
461  $out .= $indent . Xml::element( 'origin', null, strval( $slot->getOrigin() ) ) . "\n";
462  }
463 
464  $contentModel = $slot->getModel();
465  $contentHandler = MediaWikiServices::getInstance()
466  ->getContentHandlerFactory()
467  ->getContentHandler( $contentModel );
468  $contentFormat = $contentHandler->getDefaultFormat();
469 
470  // XXX: The content format is only relevant when actually outputting serialized content.
471  // It should probably be an attribute on the text tag.
472  $out .= $indent . Xml::element( 'model', null, strval( $contentModel ) ) . "\n";
473  $out .= $indent . Xml::element( 'format', null, strval( $contentFormat ) ) . "\n";
474 
475  $textAttributes = [
476  'bytes' => $this->invokeLenient(
477  static function () use ( $slot ) {
478  return $slot->getSize();
479  },
480  'failed to determine size for slot ' . $slot->getRole() . ' of revision '
481  . $slot->getRevision()
482  ) ?: '0'
483  ];
484 
485  if ( $isV11 ) {
486  $textAttributes['sha1'] = $this->invokeLenient(
487  static function () use ( $slot ) {
488  return $slot->getSha1();
489  },
490  'failed to determine sha1 for slot ' . $slot->getRole() . ' of revision '
491  . $slot->getRevision()
492  ) ?: '';
493  }
494 
495  if ( $contentMode === self::WRITE_CONTENT ) {
496  $content = $this->invokeLenient(
497  static function () use ( $slot ) {
498  return $slot->getContent();
499  },
500  'failed to load content for slot ' . $slot->getRole() . ' of revision '
501  . $slot->getRevision()
502  );
503 
504  if ( $content === null ) {
505  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
506  } else {
507  $out .= $this->writeText( $content, $textAttributes, $indent );
508  }
509  } elseif ( $contentMode === self::WRITE_STUB_DELETED ) {
510  // write <text> placeholder tag
511  $textAttributes['deleted'] = 'deleted';
512  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
513  } else {
514  // write <text> stub tag
515  if ( $isV11 ) {
516  $textAttributes['location'] = $slot->getAddress();
517  }
518 
519  if ( $isMain ) {
520  // Output the numerical text ID if possible, for backwards compatibility.
521  // Note that this is currently the ONLY reason we have a BlobStore here at all.
522  // When removing this line, check whether the BlobStore has become unused.
523  try {
524  // NOTE: this will only work for addresses of the form "tt:12345".
525  // If we want to support other kinds of addresses in the future,
526  // we will have to silently ignore failures here.
527  // For now, this fails for "tt:0", which is present in the WMF production
528  // database as of July 2019, due to data corruption.
529  $textId = $this->getBlobStore()->getTextIdFromAddress( $slot->getAddress() );
530  } catch ( InvalidArgumentException $ex ) {
531  MWDebug::warning( 'Bad content address for slot ' . $slot->getRole()
532  . ' of revision ' . $slot->getRevision() . ': ' . $ex->getMessage() );
533  $textId = 0;
534  }
535 
536  if ( is_int( $textId ) ) {
537  $textAttributes['id'] = $textId;
538  }
539  }
540 
541  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
542  }
543 
544  if ( !$isMain ) {
545  $out .= ' ' . Xml::closeElement( 'content' ) . "\n";
546  }
547 
548  return $out;
549  }
550 
558  private function writeText( Content $content, $textAttributes, $indent ) {
559  $out = '';
560 
561  $contentHandler = $content->getContentHandler();
562  $contentFormat = $contentHandler->getDefaultFormat();
563 
564  if ( $content instanceof TextContent ) {
565  // HACK: For text based models, bypass the serialization step. This allows extensions (like Flow)
566  // that use incompatible combinations of serialization format and content model.
567  $data = $content->getNativeData();
568  } else {
569  $data = $content->serialize( $contentFormat );
570  }
571 
572  $data = $contentHandler->exportTransform( $data, $contentFormat );
573  $textAttributes['bytes'] = $size = strlen( $data ); // make sure to use the actual size
574  $textAttributes['xml:space'] = 'preserve';
575  $out .= $indent . Xml::elementClean( 'text', $textAttributes, strval( $data ) ) . "\n";
576 
577  return $out;
578  }
579 
587  public function writeLogItem( $row ) {
588  $out = " <logitem>\n";
589  $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
590 
591  $out .= $this->writeTimestamp( $row->log_timestamp, " " );
592 
593  if ( $row->log_deleted & LogPage::DELETED_USER ) {
594  $out .= " " . Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
595  } else {
596  $out .= $this->writeContributor( $row->actor_user, $row->actor_name, " " );
597  }
598 
599  if ( $row->log_deleted & LogPage::DELETED_COMMENT ) {
600  $out .= " " . Xml::element( 'comment', [ 'deleted' => 'deleted' ] ) . "\n";
601  } else {
602  $comment = CommentStore::getStore()->getComment( 'log_comment', $row )->text;
603  if ( $comment != '' ) {
604  // @phan-suppress-next-line SecurityCheck-DoubleEscaped CommentStore is polluted by truncate
605  $out .= " " . Xml::elementClean( 'comment', null, strval( $comment ) ) . "\n";
606  }
607  }
608 
609  $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
610  $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
611 
612  if ( $row->log_deleted & LogPage::DELETED_ACTION ) {
613  $out .= " " . Xml::element( 'text', [ 'deleted' => 'deleted' ] ) . "\n";
614  } else {
615  $title = Title::makeTitle( $row->log_namespace, $row->log_title );
616  $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
617  $out .= " " . Xml::elementClean( 'params',
618  [ 'xml:space' => 'preserve' ],
619  strval( $row->log_params ) ) . "\n";
620  }
621 
622  $out .= " </logitem>\n";
623 
624  return $out;
625  }
626 
632  public function writeTimestamp( $timestamp, $indent = " " ) {
633  $ts = wfTimestamp( TS_ISO_8601, $timestamp );
634  return $indent . Xml::element( 'timestamp', null, $ts ) . "\n";
635  }
636 
643  public function writeContributor( $id, $text, $indent = " " ) {
644  $out = $indent . "<contributor>\n";
645  if ( $id || !IPUtils::isValid( $text ) ) {
646  $out .= $indent . " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
647  $out .= $indent . " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
648  } else {
649  $out .= $indent . " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
650  }
651  $out .= $indent . "</contributor>\n";
652  return $out;
653  }
654 
661  public function writeUploads( $row, $dumpContents = false ) {
662  if ( $row->page_namespace == NS_FILE ) {
663  $img = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
664  ->newFile( $row->page_title );
665  if ( $img && $img->exists() ) {
666  $out = '';
667  foreach ( array_reverse( $img->getHistory() ) as $ver ) {
668  $out .= $this->writeUpload( $ver, $dumpContents );
669  }
670  $out .= $this->writeUpload( $img, $dumpContents );
671  return $out;
672  }
673  }
674  return '';
675  }
676 
682  private function writeUpload( $file, $dumpContents = false ) {
683  if ( $file->isOld() ) {
685  '@phan-var OldLocalFile $file';
686  $archiveName = " " .
687  Xml::element( 'archivename', null, $file->getArchiveName() ) . "\n";
688  } else {
689  $archiveName = '';
690  }
691  if ( $dumpContents ) {
692  $be = $file->getRepo()->getBackend();
693  # Dump file as base64
694  # Uses only XML-safe characters, so does not need escaping
695  # @todo Too bad this loads the contents into memory (script might swap)
696  $contents = ' <contents encoding="base64">' .
697  chunk_split( base64_encode(
698  $be->getFileContents( [ 'src' => $file->getPath() ] ) ) ) .
699  " </contents>\n";
700  } else {
701  $contents = '';
702  }
703  $uploader = $file->getUploader( File::FOR_PUBLIC );
704  if ( $uploader ) {
705  $uploader = $this->writeContributor( $uploader->getId(), $uploader->getName() );
706  } else {
707  $uploader = Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
708  }
709  $comment = $file->getDescription( File::FOR_PUBLIC );
710  if ( ( $comment ?? '' ) !== '' ) {
711  $comment = Xml::elementClean( 'comment', null, $comment );
712  } else {
713  $comment = Xml::element( 'comment', [ 'deleted' => 'deleted' ] );
714  }
715  return " <upload>\n" .
716  $this->writeTimestamp( $file->getTimestamp() ) .
717  $uploader .
718  " " . $comment . "\n" .
719  " " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
720  $archiveName .
721  " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" .
722  " " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
723  " " . Xml::element( 'sha1base36', null, $file->getSha1() ) . "\n" .
724  " " . Xml::element( 'rel', null, $file->getRel() ) . "\n" .
725  $contents .
726  " </upload>\n";
727  }
728 
739  public static function canonicalTitle( Title $title ) {
740  if ( $title->isExternal() ) {
741  return $title->getPrefixedText();
742  }
743 
744  $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
745  getFormattedNsText( $title->getNamespace() );
746 
747  // @todo Emit some kind of warning to the user if $title->getNamespace() !==
748  // NS_MAIN and $prefix === '' (viz. pages in an unregistered namespace)
749 
750  if ( $prefix !== '' ) {
751  $prefix .= ':';
752  }
753 
754  return $prefix . $title->getText();
755  }
756 }
XmlDumpWriter\openStream
openStream()
Opens the XML output stream's root "<mediawiki>" element.
Definition: XmlDumpWriter.php:122
XmlDumpWriter\getBlobStore
getBlobStore()
Definition: XmlDumpWriter.php:301
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:47
XmlDumpWriter\writeSlot
writeSlot(SlotRecord $slot, $contentMode)
Definition: XmlDumpWriter.php:441
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:203
MediaWiki\Revision\SuppressedDataException
Exception raised in response to an audience check when attempting to access suppressed information wi...
Definition: SuppressedDataException.php:33
XmlDumpWriter\openPage
openPage( $row)
Opens a "<page>" section on the output stream, with data from the given database row.
Definition: XmlDumpWriter.php:241
XmlDumpWriter\dbname
dbname()
Definition: XmlDumpWriter.php:173
MediaWiki\Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:89
XML_DUMP_SCHEMA_VERSION_10
const XML_DUMP_SCHEMA_VERSION_10
Definition: Defines.php:313
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:53
XmlDumpWriter\siteInfo
siteInfo()
Definition: XmlDumpWriter.php:149
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1649
MW_VERSION
const MW_VERSION
The running version of MediaWiki.
Definition: Defines.php:36
XmlDumpWriter\homelink
homelink()
Definition: XmlDumpWriter.php:188
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
MediaWiki\Revision\SlotRecord\getSha1
getSha1()
Returns the content size.
Definition: SlotRecord.php:556
Title\newMainPage
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
Definition: Title.php:710
XmlDumpWriter\$supportedSchemas
static string[] $supportedSchemas
the schema versions supported for output @final
Definition: XmlDumpWriter.php:57
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:111
File\FOR_PUBLIC
const FOR_PUBLIC
Definition: File.php:87
XmlDumpWriter\writeLogItem
writeLogItem( $row)
Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.
Definition: XmlDumpWriter.php:587
Xml\elementClean
static elementClean( $element, $attribs=[], $contents='')
Format an XML element as with self::element(), but run text through the content language's normalize(...
Definition: Xml.php:93
MWException
MediaWiki exception.
Definition: MWException.php:29
XmlDumpWriter\WRITE_CONTENT
const WRITE_CONTENT
Output serialized revision content.
Definition: XmlDumpWriter.php:42
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:40
XmlDumpWriter\canonicalTitle
static canonicalTitle(Title $title)
Return prefixed text form of title, but using the content language's canonical namespace.
Definition: XmlDumpWriter.php:739
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:577
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:41
XmlDumpWriter\writeContributor
writeContributor( $id, $text, $indent=" ")
Definition: XmlDumpWriter.php:643
Title\isValidRedirectTarget
isValidRedirectTarget()
Check if this Title is a valid redirect target.
Definition: Title.php:3829
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:42
XML_DUMP_SCHEMA_VERSION_11
const XML_DUMP_SCHEMA_VERSION_11
Definition: Defines.php:314
$title
$title
Definition: testCompression.php:38
XmlDumpWriter\__construct
__construct( $contentMode=self::WRITE_CONTENT, $schemaVersion=XML_DUMP_SCHEMA_VERSION_11)
Definition: XmlDumpWriter.php:90
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:648
XmlDumpWriter\namespaces
namespaces()
Definition: XmlDumpWriter.php:205
XmlDumpWriter\closeStream
closeStream()
Closes the output stream with the closing root element.
Definition: XmlDumpWriter.php:230
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:39
XmlDumpWriter\WRITE_STUB_DELETED
const WRITE_STUB_DELETED
Only output subs for revision content, indicating that the content has been deleted/suppressed.
Definition: XmlDumpWriter.php:51
MediaWiki\Revision\SlotRecord\getAddress
getAddress()
Returns the address of this slot's content.
Definition: SlotRecord.php:517
$content
$content
Definition: router.php:76
MediaWiki\Revision\SlotRecord\getOrigin
getOrigin()
Returns the revision ID of the revision that originated the slot's content.
Definition: SlotRecord.php:423
XmlDumpWriter\writeText
writeText(Content $content, $textAttributes, $indent)
Definition: XmlDumpWriter.php:558
XmlDumpWriter\getRevisionStore
getRevisionStore()
Definition: XmlDumpWriter.php:294
XmlDumpWriter\caseSetting
caseSetting()
Definition: XmlDumpWriter.php:195
XmlDumpWriter\writeUpload
writeUpload( $file, $dumpContents=false)
Definition: XmlDumpWriter.php:682
XmlDumpWriter\writeTimestamp
writeTimestamp( $timestamp, $indent=" ")
Definition: XmlDumpWriter.php:632
TextContent
Content object implementation for representing flat text.
Definition: TextContent.php:39
XmlDumpWriter\sitename
sitename()
Definition: XmlDumpWriter.php:165
Content
Base interface for content objects.
Definition: Content.php:35
XmlDumpWriter\WRITE_STUB
const WRITE_STUB
Only output subs for revision content.
Definition: XmlDumpWriter.php:45
Title
Represents a title within MediaWiki.
Definition: Title.php:47
MediaWiki\Revision\SlotRecord\getSize
getSize()
Returns the content size.
Definition: SlotRecord.php:540
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:120
XmlDumpWriter\$contentMode
int $contentMode
Whether to output revision content or just stubs.
Definition: XmlDumpWriter.php:79
XmlDumpWriter
Definition: XmlDumpWriter.php:39
XmlDumpWriter\writeRevision
writeRevision( $row, $slotRows=null)
Dumps a "<revision>" section on the output stream, with data filled in from the given database row.
Definition: XmlDumpWriter.php:344
XmlDumpWriter\generator
generator()
Definition: XmlDumpWriter.php:181
XmlDumpWriter\$currentTitle
Title null $currentTitle
Title of the currently processed page.
Definition: XmlDumpWriter.php:74
XmlDumpWriter\$hookRunner
HookRunner $hookRunner
Definition: XmlDumpWriter.php:82
MediaWiki\Revision\SlotRecord\getRole
getRole()
Returns the role of the slot.
Definition: SlotRecord.php:507
XmlDumpWriter\$schemaVersion
string $schemaVersion
which schema version the generated XML should comply to.
Definition: XmlDumpWriter.php:67
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:557
NS_FILE
const NS_FILE
Definition: Defines.php:70
MWDebug\warning
static warning( $msg, $callerOffset=1, $level=E_USER_NOTICE, $log='auto')
Adds a warning entry to the log.
Definition: MWDebug.php:182
CommentStore\getStore
static getStore()
Definition: CommentStore.php:120
MediaWiki\Revision\SlotRecord\getContent
getContent()
Returns the Content of the given slot.
Definition: SlotRecord.php:317
MediaWiki\Revision\SlotRecord\getModel
getModel()
Returns the content model.
Definition: SlotRecord.php:584
XmlDumpWriter\closePage
closePage()
Closes a "<page>" section on the output stream.
Definition: XmlDumpWriter.php:281
XmlDumpWriter\writeUploads
writeUploads( $row, $dumpContents=false)
Warning! This data is potentially inconsistent.
Definition: XmlDumpWriter.php:661
MediaWiki\Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:40
MediaWiki\Revision\SlotRecord\getRevision
getRevision()
Returns the ID of the revision this slot is associated with.
Definition: SlotRecord.php:414
XmlDumpWriter\invokeLenient
invokeLenient( $callback, $warning)
Invokes the given callback, catching and logging any storage related exceptions.
Definition: XmlDumpWriter.php:317