MediaWiki  master
XmlDumpWriter.php
Go to the documentation of this file.
1 <?php
31 use Wikimedia\Assert\Assert;
32 use Wikimedia\IPUtils;
33 
38 
40  public const WRITE_CONTENT = 0;
41 
43  public const WRITE_STUB = 1;
44 
49  private const WRITE_STUB_DELETED = 2;
50 
55  public static $supportedSchemas = [
58  ];
59 
65  private $schemaVersion;
66 
72  private $currentTitle = null;
73 
77  private $contentMode;
78 
85  public function __construct(
86  $contentMode = self::WRITE_CONTENT,
88  ) {
89  Assert::parameter(
90  in_array( $contentMode, [ self::WRITE_CONTENT, self::WRITE_STUB ] ),
91  '$contentMode',
92  'must be one of the following constants: WRITE_CONTENT or WRITE_STUB.'
93  );
94 
95  Assert::parameter(
96  in_array( $schemaVersion, self::$supportedSchemas ),
97  '$schemaVersion',
98  'must be one of the following schema versions: '
99  . implode( ',', self::$supportedSchemas )
100  );
101 
102  $this->contentMode = $contentMode;
103  $this->schemaVersion = $schemaVersion;
104  }
105 
116  function openStream() {
117  $ver = $this->schemaVersion;
118  return Xml::element( 'mediawiki', [
119  'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
120  'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
121  /*
122  * When a new version of the schema is created, it needs staging on mediawiki.org.
123  * This requires a change in the operations/mediawiki-config git repo.
124  *
125  * Create a changeset like https://gerrit.wikimedia.org/r/#/c/149643/ in which
126  * you copy in the new xsd file.
127  *
128  * After it is reviewed, merged and deployed (sync-docroot), the index.html needs purging.
129  * echo "https://www.mediawiki.org/xml/index.html" | mwscript purgeList.php --wiki=aawiki
130  */
131  'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
132  "http://www.mediawiki.org/xml/export-$ver.xsd",
133  'version' => $ver,
134  'xml:lang' => MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() ],
135  null ) .
136  "\n" .
137  $this->siteInfo();
138  }
139 
143  function siteInfo() {
144  $info = [
145  $this->sitename(),
146  $this->dbname(),
147  $this->homelink(),
148  $this->generator(),
149  $this->caseSetting(),
150  $this->namespaces() ];
151  return " <siteinfo>\n " .
152  implode( "\n ", $info ) .
153  "\n </siteinfo>\n";
154  }
155 
159  function sitename() {
160  global $wgSitename;
161  return Xml::element( 'sitename', [], $wgSitename );
162  }
163 
167  function dbname() {
168  global $wgDBname;
169  return Xml::element( 'dbname', [], $wgDBname );
170  }
171 
175  function generator() {
176  return Xml::element( 'generator', [], 'MediaWiki ' . MW_VERSION );
177  }
178 
182  function homelink() {
183  return Xml::element( 'base', [], Title::newMainPage()->getCanonicalURL() );
184  }
185 
189  function caseSetting() {
190  global $wgCapitalLinks;
191  // "case-insensitive" option is reserved for future
192  $sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
193  return Xml::element( 'case', [], $sensitivity );
194  }
195 
199  function namespaces() {
200  $spaces = "<namespaces>\n";
201  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
202  foreach (
203  MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
204  as $ns => $title
205  ) {
206  $spaces .= ' ' .
207  Xml::element( 'namespace',
208  [
209  'key' => $ns,
210  'case' => $nsInfo->isCapitalized( $ns )
211  ? 'first-letter' : 'case-sensitive',
212  ], $title ) . "\n";
213  }
214  $spaces .= " </namespaces>";
215  return $spaces;
216  }
217 
224  function closeStream() {
225  return "</mediawiki>\n";
226  }
227 
235  public function openPage( $row ) {
236  $out = " <page>\n";
237  $this->currentTitle = Title::newFromRow( $row );
238  $canonicalTitle = self::canonicalTitle( $this->currentTitle );
239  $out .= ' ' . Xml::elementClean( 'title', [], $canonicalTitle ) . "\n";
240  $out .= ' ' . Xml::element( 'ns', [], strval( $row->page_namespace ) ) . "\n";
241  $out .= ' ' . Xml::element( 'id', [], strval( $row->page_id ) ) . "\n";
242  if ( $row->page_is_redirect ) {
243  $page = WikiPage::factory( $this->currentTitle );
244  $redirect = $page->getRedirectTarget();
245  if ( $redirect instanceof Title && $redirect->isValidRedirectTarget() ) {
246  $out .= ' ';
247  $out .= Xml::element( 'redirect', [ 'title' => self::canonicalTitle( $redirect ) ] );
248  $out .= "\n";
249  }
250  }
251 
252  if ( $row->page_restrictions != '' ) {
253  $out .= ' ' . Xml::element( 'restrictions', [],
254  strval( $row->page_restrictions ) ) . "\n";
255  }
256 
257  Hooks::run( 'XmlDumpWriterOpenPage', [ $this, &$out, $row, $this->currentTitle ] );
258 
259  return $out;
260  }
261 
268  function closePage() {
269  if ( $this->currentTitle !== null ) {
270  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
271  // In rare cases, link cache has the same key for some pages which
272  // might be read as part of the same batch. T220424 and T220316
273  $linkCache->clearLink( $this->currentTitle );
274  }
275  return " </page>\n";
276  }
277 
281  private function getRevisionStore() {
282  return MediaWikiServices::getInstance()->getRevisionStore();
283  }
284 
288  private function getBlobStore() {
289  return MediaWikiServices::getInstance()->getBlobStore();
290  }
291 
305  private function invokeLenient( $obj, $method, $warning, $args = [] ) {
306  try {
307  return call_user_func_array( [ $obj, $method ], $args );
308  } catch ( SuppressedDataException $ex ) {
309  return null;
310  } catch ( Exception $ex ) {
311  if ( $ex instanceof MWException || $ex instanceof RuntimeException ||
312  $ex instanceof InvalidArgumentException ) {
313  MWDebug::warning( $warning . ': ' . $ex->getMessage() );
314  return null;
315  } else {
316  throw $ex;
317  }
318  }
319  }
320 
333  function writeRevision( $row, $slotRows = null ) {
334  $rev = $this->getRevisionStore()->newRevisionFromRowAndSlots(
335  $row,
336  $slotRows,
337  0,
338  $this->currentTitle
339  );
340 
341  $out = " <revision>\n";
342  $out .= " " . Xml::element( 'id', null, strval( $rev->getId() ) ) . "\n";
343 
344  if ( $rev->getParentId() ) {
345  $out .= " " . Xml::element( 'parentid', null, strval( $rev->getParentId() ) ) . "\n";
346  }
347 
348  $out .= $this->writeTimestamp( $rev->getTimestamp() );
349 
350  if ( $rev->isDeleted( RevisionRecord::DELETED_USER ) ) {
351  $out .= " " . Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
352  } else {
353  // empty values get written out as uid 0, see T224221
354  $user = $rev->getUser();
355  $out .= $this->writeContributor(
356  $user ? $user->getId() : 0,
357  $user ? $user->getName() : ''
358  );
359  }
360 
361  if ( $rev->isMinor() ) {
362  $out .= " <minor/>\n";
363  }
364  if ( $rev->isDeleted( RevisionRecord::DELETED_COMMENT ) ) {
365  $out .= " " . Xml::element( 'comment', [ 'deleted' => 'deleted' ] ) . "\n";
366  } else {
367  if ( $rev->getComment()->text != '' ) {
368  $out .= " "
369  . Xml::elementClean( 'comment', [], strval( $rev->getComment()->text ) )
370  . "\n";
371  }
372  }
373 
374  $contentMode = $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ? self::WRITE_STUB_DELETED
376 
377  foreach ( $rev->getSlots()->getSlots() as $slot ) {
378  $out .= $this->writeSlot( $slot, $contentMode );
379  }
380 
381  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
382  $out .= " <sha1/>\n";
383  } else {
384  $sha1 = $this->invokeLenient(
385  $rev,
386  'getSha1',
387  'failed to determine sha1 for revision ' . $rev->getId()
388  );
389  $out .= " " . Xml::element( 'sha1', null, strval( $sha1 ) ) . "\n";
390  }
391 
392  // Avoid PHP 7.1 warning from passing $this by reference
393  $writer = $this;
394  $text = '';
395  if ( $contentMode === self::WRITE_CONTENT ) {
397  $content = $this->invokeLenient(
398  $rev,
399  'getContent',
400  'Failed to load main slot content of revision ' . $rev->getId(),
401  [ SlotRecord::MAIN, RevisionRecord::RAW ]
402  );
403 
404  $text = $content ? $content->serialize() : '';
405  }
406  Hooks::run( 'XmlDumpWriterWriteRevision', [ &$writer, &$out, $row, $text, $rev ] );
407 
408  $out .= " </revision>\n";
409 
410  return $out;
411  }
412 
419  private function writeSlot( SlotRecord $slot, $contentMode ) {
420  $isMain = $slot->getRole() === SlotRecord::MAIN;
421  $isV11 = $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11;
422 
423  if ( !$isV11 && !$isMain ) {
424  // ignore extra slots
425  return '';
426  }
427 
428  $out = '';
429  $indent = ' ';
430 
431  if ( !$isMain ) {
432  // non-main slots are wrapped into an additional element.
433  $out .= ' ' . Xml::openElement( 'content' ) . "\n";
434  $indent .= ' ';
435  $out .= $indent . Xml::element( 'role', null, strval( $slot->getRole() ) ) . "\n";
436  }
437 
438  if ( $isV11 ) {
439  $out .= $indent . Xml::element( 'origin', null, strval( $slot->getOrigin() ) ) . "\n";
440  }
441 
442  $contentModel = $slot->getModel();
443  $contentHandler = MediaWikiServices::getInstance()
444  ->getContentHandlerFactory()
445  ->getContentHandler( $contentModel );
446  $contentFormat = $contentHandler->getDefaultFormat();
447 
448  // XXX: The content format is only relevant when actually outputting serialized content.
449  // It should probably be an attribute on the text tag.
450  $out .= $indent . Xml::element( 'model', null, strval( $contentModel ) ) . "\n";
451  $out .= $indent . Xml::element( 'format', null, strval( $contentFormat ) ) . "\n";
452 
453  $textAttributes = [
454  'bytes' => $this->invokeLenient(
455  $slot,
456  'getSize',
457  'failed to determine size for slot ' . $slot->getRole() . ' of revision '
458  . $slot->getRevision()
459  ) ?: '0'
460  ];
461 
462  if ( $isV11 ) {
463  $textAttributes['sha1'] = $this->invokeLenient(
464  $slot,
465  'getSha1',
466  'failed to determine sha1 for slot ' . $slot->getRole() . ' of revision '
467  . $slot->getRevision()
468  ) ?: '';
469  }
470 
471  if ( $contentMode === self::WRITE_CONTENT ) {
472  $content = $this->invokeLenient(
473  $slot,
474  'getContent',
475  'failed to load content for slot ' . $slot->getRole() . ' of revision '
476  . $slot->getRevision()
477  );
478 
479  if ( $content === null ) {
480  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
481  } else {
482  $out .= $this->writeText( $content, $textAttributes, $indent );
483  }
484  } elseif ( $contentMode === self::WRITE_STUB_DELETED ) {
485  // write <text> placeholder tag
486  $textAttributes['deleted'] = 'deleted';
487  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
488  } else {
489  // write <text> stub tag
490  if ( $isV11 ) {
491  $textAttributes['location'] = $slot->getAddress();
492  }
493 
494  if ( $isMain ) {
495  // Output the numerical text ID if possible, for backwards compatibility.
496  // Note that this is currently the ONLY reason we have a BlobStore here at all.
497  // When removing this line, check whether the BlobStore has become unused.
498  try {
499  // NOTE: this will only work for addresses of the form "tt:12345".
500  // If we want to support other kinds of addresses in the future,
501  // we will have to silently ignore failures here.
502  // For now, this fails for "tt:0", which is present in the WMF production
503  // database of of Juli 2019, due to data corruption.
504  $textId = $this->getBlobStore()->getTextIdFromAddress( $slot->getAddress() );
505  } catch ( InvalidArgumentException $ex ) {
506  MWDebug::warning( 'Bad content address for slot ' . $slot->getRole()
507  . ' of revision ' . $slot->getRevision() . ': ' . $ex->getMessage() );
508  $textId = 0;
509  }
510 
511  if ( is_int( $textId ) ) {
512  $textAttributes['id'] = $textId;
513  }
514  }
515 
516  $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";
517  }
518 
519  if ( !$isMain ) {
520  $out .= ' ' . Xml::closeElement( 'content' ) . "\n";
521  }
522 
523  return $out;
524  }
525 
533  private function writeText( Content $content, $textAttributes, $indent ) {
534  $out = '';
535 
536  $contentHandler = $content->getContentHandler();
537  $contentFormat = $contentHandler->getDefaultFormat();
538 
539  if ( $content instanceof TextContent ) {
540  // HACK: For text based models, bypass the serialization step. This allows extensions (like Flow)
541  // that use incompatible combinations of serialization format and content model.
542  $data = $content->getNativeData();
543  } else {
544  $data = $content->serialize( $contentFormat );
545  }
546 
547  $data = $contentHandler->exportTransform( $data, $contentFormat );
548  $textAttributes['bytes'] = $size = strlen( $data ); // make sure to use the actual size
549  $textAttributes['xml:space'] = 'preserve';
550  $out .= $indent . Xml::elementClean( 'text', $textAttributes, strval( $data ) ) . "\n";
551 
552  return $out;
553  }
554 
563  function writeLogItem( $row ) {
564  $out = " <logitem>\n";
565  $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
566 
567  $out .= $this->writeTimestamp( $row->log_timestamp, " " );
568 
569  if ( $row->log_deleted & LogPage::DELETED_USER ) {
570  $out .= " " . Xml::element( 'contributor', [ 'deleted' => 'deleted' ] ) . "\n";
571  } else {
572  $out .= $this->writeContributor( $row->log_user, $row->user_name, " " );
573  }
574 
575  if ( $row->log_deleted & LogPage::DELETED_COMMENT ) {
576  $out .= " " . Xml::element( 'comment', [ 'deleted' => 'deleted' ] ) . "\n";
577  } else {
578  $comment = CommentStore::getStore()->getComment( 'log_comment', $row )->text;
579  if ( $comment != '' ) {
580  $out .= " " . Xml::elementClean( 'comment', null, strval( $comment ) ) . "\n";
581  }
582  }
583 
584  $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
585  $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
586 
587  if ( $row->log_deleted & LogPage::DELETED_ACTION ) {
588  $out .= " " . Xml::element( 'text', [ 'deleted' => 'deleted' ] ) . "\n";
589  } else {
590  $title = Title::makeTitle( $row->log_namespace, $row->log_title );
591  $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
592  $out .= " " . Xml::elementClean( 'params',
593  [ 'xml:space' => 'preserve' ],
594  strval( $row->log_params ) ) . "\n";
595  }
596 
597  $out .= " </logitem>\n";
598 
599  return $out;
600  }
601 
607  function writeTimestamp( $timestamp, $indent = " " ) {
608  $ts = wfTimestamp( TS_ISO_8601, $timestamp );
609  return $indent . Xml::element( 'timestamp', null, $ts ) . "\n";
610  }
611 
618  function writeContributor( $id, $text, $indent = " " ) {
619  $out = $indent . "<contributor>\n";
620  if ( $id || !IPUtils::isValid( $text ) ) {
621  $out .= $indent . " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
622  $out .= $indent . " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
623  } else {
624  $out .= $indent . " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
625  }
626  $out .= $indent . "</contributor>\n";
627  return $out;
628  }
629 
636  function writeUploads( $row, $dumpContents = false ) {
637  if ( $row->page_namespace == NS_FILE ) {
638  $img = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
639  ->newFile( $row->page_title );
640  if ( $img && $img->exists() ) {
641  $out = '';
642  foreach ( array_reverse( $img->getHistory() ) as $ver ) {
643  $out .= $this->writeUpload( $ver, $dumpContents );
644  }
645  $out .= $this->writeUpload( $img, $dumpContents );
646  return $out;
647  }
648  }
649  return '';
650  }
651 
657  function writeUpload( $file, $dumpContents = false ) {
658  if ( $file->isOld() ) {
660  '@phan-var OldLocalFile $file';
661  $archiveName = " " .
662  Xml::element( 'archivename', null, $file->getArchiveName() ) . "\n";
663  } else {
664  $archiveName = '';
665  }
666  if ( $dumpContents ) {
667  $be = $file->getRepo()->getBackend();
668  # Dump file as base64
669  # Uses only XML-safe characters, so does not need escaping
670  # @todo Too bad this loads the contents into memory (script might swap)
671  $contents = ' <contents encoding="base64">' .
672  chunk_split( base64_encode(
673  $be->getFileContents( [ 'src' => $file->getPath() ] ) ) ) .
674  " </contents>\n";
675  } else {
676  $contents = '';
677  }
678  if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
679  $comment = Xml::element( 'comment', [ 'deleted' => 'deleted' ] );
680  } else {
681  $comment = Xml::elementClean( 'comment', null, strval( $file->getDescription() ) );
682  }
683  return " <upload>\n" .
684  $this->writeTimestamp( $file->getTimestamp() ) .
685  $this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) .
686  " " . $comment . "\n" .
687  " " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
688  $archiveName .
689  " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" .
690  " " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
691  " " . Xml::element( 'sha1base36', null, $file->getSha1() ) . "\n" .
692  " " . Xml::element( 'rel', null, $file->getRel() ) . "\n" .
693  $contents .
694  " </upload>\n";
695  }
696 
707  public static function canonicalTitle( Title $title ) {
708  if ( $title->isExternal() ) {
709  return $title->getPrefixedText();
710  }
711 
712  $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
713  getFormattedNsText( $title->getNamespace() );
714 
715  // @todo Emit some kind of warning to the user if $title->getNamespace() !==
716  // NS_MAIN and $prefix === '' (viz. pages in an unregistered namespace)
717 
718  if ( $prefix !== '' ) {
719  $prefix .= ':';
720  }
721 
722  return $prefix . $title->getText();
723  }
724 }
XmlDumpWriter\openStream
openStream()
Opens the XML output stream's root "<mediawiki>" element.
Definition: XmlDumpWriter.php:116
XmlDumpWriter\getBlobStore
getBlobStore()
Definition: XmlDumpWriter.php:288
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:46
$wgDBname
$wgDBname
Current wiki database name.
Definition: DefaultSettings.php:1925
XmlDumpWriter\writeSlot
writeSlot(SlotRecord $slot, $contentMode)
Definition: XmlDumpWriter.php:419
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:137
Revision\SuppressedDataException
Exception raised in response to an audience check when attempting to access suppressed information wi...
Definition: SuppressedDataException.php:32
XmlDumpWriter\openPage
openPage( $row)
Opens a "<page>" section on the output stream, with data from the given database row.
Definition: XmlDumpWriter.php:235
XmlDumpWriter\dbname
dbname()
Definition: XmlDumpWriter.php:167
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:77
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
XmlDumpWriter\siteInfo
siteInfo()
Definition: XmlDumpWriter.php:143
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1809
MW_VERSION
const MW_VERSION
The running version of MediaWiki.
Definition: Defines.php:39
XmlDumpWriter\homelink
homelink()
Definition: XmlDumpWriter.php:182
NS_FILE
const NS_FILE
Definition: Defines.php:75
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
Title\newMainPage
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
Definition: Title.php:657
Revision\SlotRecord\getRevision
getRevision()
Returns the ID of the revision this slot is associated with.
Definition: SlotRecord.php:396
XmlDumpWriter\$supportedSchemas
static string[] $supportedSchemas
the schema versions supported for output @final
Definition: XmlDumpWriter.php:55
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:108
XmlDumpWriter\writeLogItem
writeLogItem( $row)
Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.
Definition: XmlDumpWriter.php:563
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:90
Revision\SlotRecord\getOrigin
getOrigin()
Returns the revision ID of the revision that originated the slot's content.
Definition: SlotRecord.php:405
MWException
MediaWiki exception.
Definition: MWException.php:26
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:64
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:143
XmlDumpWriter\WRITE_CONTENT
const WRITE_CONTENT
Output serialized revision content.
Definition: XmlDumpWriter.php:40
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:35
XmlDumpWriter\canonicalTitle
static canonicalTitle(Title $title)
Return prefixed text form of title, but using the content language's canonical namespace.
Definition: XmlDumpWriter.php:707
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:527
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:36
Revision\SlotRecord\getRole
getRole()
Returns the role of the slot.
Definition: SlotRecord.php:489
XmlDumpWriter\writeContributor
writeContributor( $id, $text, $indent=" ")
Definition: XmlDumpWriter.php:618
Title\isValidRedirectTarget
isValidRedirectTarget()
Check if this Title is a valid redirect target.
Definition: Title.php:4314
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
$args
if( $line===false) $args
Definition: mcc.php:124
Revision\SlotRecord\getModel
getModel()
Returns the content model.
Definition: SlotRecord.php:566
$title
$title
Definition: testCompression.php:38
XmlDumpWriter\__construct
__construct( $contentMode=self::WRITE_CONTENT, $schemaVersion=XML_DUMP_SCHEMA_VERSION_11)
Definition: XmlDumpWriter.php:85
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:595
Revision\SlotRecord\getAddress
getAddress()
Returns the address of this slot's content.
Definition: SlotRecord.php:499
XmlDumpWriter\namespaces
namespaces()
Definition: XmlDumpWriter.php:199
XmlDumpWriter\closeStream
closeStream()
Closes the output stream with the closing root element.
Definition: XmlDumpWriter.php:224
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:34
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:49
$content
$content
Definition: router.php:78
XmlDumpWriter\writeText
writeText(Content $content, $textAttributes, $indent)
Definition: XmlDumpWriter.php:533
XmlDumpWriter\getRevisionStore
getRevisionStore()
Definition: XmlDumpWriter.php:281
XmlDumpWriter\caseSetting
caseSetting()
Definition: XmlDumpWriter.php:189
$wgSitename
$wgSitename
Name of the site.
Definition: DefaultSettings.php:81
XmlDumpWriter\writeUpload
writeUpload( $file, $dumpContents=false)
Definition: XmlDumpWriter.php:657
XML_DUMP_SCHEMA_VERSION_11
const XML_DUMP_SCHEMA_VERSION_11
Definition: Defines.php:318
XmlDumpWriter\writeTimestamp
writeTimestamp( $timestamp, $indent=" ")
Definition: XmlDumpWriter.php:607
TextContent
Content object implementation for representing flat text.
Definition: TextContent.php:37
XmlDumpWriter\sitename
sitename()
Definition: XmlDumpWriter.php:159
XmlDumpWriter\invokeLenient
invokeLenient( $obj, $method, $warning, $args=[])
Invokes the given method on the given object, catching and logging any storage related exceptions.
Definition: XmlDumpWriter.php:305
Content
Base interface for content objects.
Definition: Content.php:34
XmlDumpWriter\WRITE_STUB
const WRITE_STUB
Only output subs for revision content.
Definition: XmlDumpWriter.php:43
Title
Represents a title within MediaWiki.
Definition: Title.php:42
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
$wgCapitalLinks
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
Definition: DefaultSettings.php:4317
XmlDumpWriter\$contentMode
int $contentMode
Whether to output revision content or just stubs.
Definition: XmlDumpWriter.php:77
XmlDumpWriter
Definition: XmlDumpWriter.php:37
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:333
XmlDumpWriter\generator
generator()
Definition: XmlDumpWriter.php:175
XmlDumpWriter\$currentTitle
Title null $currentTitle
Title of the currently processed page.
Definition: XmlDumpWriter.php:72
XmlDumpWriter\$schemaVersion
string $schemaVersion
which schema version the generated XML should comply to.
Definition: XmlDumpWriter.php:65
MWDebug\warning
static warning( $msg, $callerOffset=1, $level=E_USER_NOTICE, $log='auto')
Adds a warning entry to the log.
Definition: MWDebug.php:175
CommentStore\getStore
static getStore()
Definition: CommentStore.php:116
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
XML_DUMP_SCHEMA_VERSION_10
const XML_DUMP_SCHEMA_VERSION_10
Definition: Defines.php:317
XmlDumpWriter\closePage
closePage()
Closes a "<page>" section on the output stream.
Definition: XmlDumpWriter.php:268
XmlDumpWriter\writeUploads
writeUploads( $row, $dumpContents=false)
Warning! This data is potentially inconsistent.
Definition: XmlDumpWriter.php:636
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39