MediaWiki  1.23.2
Export.php
Go to the documentation of this file.
1 <?php
33 class WikiExporter {
34  var $list_authors = false; # Return distinct author list (when not returning full history)
35  var $author_list = "";
36 
39 
40  const FULL = 1;
41  const CURRENT = 2;
42  const STABLE = 4; // extension defined
43  const LOGS = 8;
44  const RANGE = 16;
45 
46  const BUFFER = 0;
47  const STREAM = 1;
48 
49  const TEXT = 0;
50  const STUB = 1;
51 
52  var $buffer;
53 
54  var $text;
55 
59  var $sink;
60 
65  public static function schemaVersion() {
66  return "0.8";
67  }
68 
85  function __construct( $db, $history = WikiExporter::CURRENT,
87  $this->db = $db;
88  $this->history = $history;
89  $this->buffer = $buffer;
90  $this->writer = new XmlDumpWriter();
91  $this->sink = new DumpOutput();
92  $this->text = $text;
93  }
94 
102  public function setOutputSink( &$sink ) {
103  $this->sink =& $sink;
104  }
105 
106  public function openStream() {
107  $output = $this->writer->openStream();
108  $this->sink->writeOpenStream( $output );
109  }
110 
111  public function closeStream() {
112  $output = $this->writer->closeStream();
113  $this->sink->writeCloseStream( $output );
114  }
115 
121  public function allPages() {
122  $this->dumpFrom( '' );
123  }
124 
132  public function pagesByRange( $start, $end ) {
133  $condition = 'page_id >= ' . intval( $start );
134  if ( $end ) {
135  $condition .= ' AND page_id < ' . intval( $end );
136  }
137  $this->dumpFrom( $condition );
138  }
139 
147  public function revsByRange( $start, $end ) {
148  $condition = 'rev_id >= ' . intval( $start );
149  if ( $end ) {
150  $condition .= ' AND rev_id < ' . intval( $end );
151  }
152  $this->dumpFrom( $condition );
153  }
154 
158  public function pageByTitle( $title ) {
159  $this->dumpFrom(
160  'page_namespace=' . $title->getNamespace() .
161  ' AND page_title=' . $this->db->addQuotes( $title->getDBkey() ) );
162  }
163 
168  public function pageByName( $name ) {
170  if ( is_null( $title ) ) {
171  throw new MWException( "Can't export invalid title" );
172  } else {
173  $this->pageByTitle( $title );
174  }
175  }
176 
180  public function pagesByName( $names ) {
181  foreach ( $names as $name ) {
182  $this->pageByName( $name );
183  }
184  }
185 
186  public function allLogs() {
187  $this->dumpFrom( '' );
188  }
189 
194  public function logsByRange( $start, $end ) {
195  $condition = 'log_id >= ' . intval( $start );
196  if ( $end ) {
197  $condition .= ' AND log_id < ' . intval( $end );
198  }
199  $this->dumpFrom( $condition );
200  }
201 
209  protected function do_list_authors( $cond ) {
210  wfProfileIn( __METHOD__ );
211  $this->author_list = "<contributors>";
212  // rev_deleted
213 
214  $res = $this->db->select(
215  array( 'page', 'revision' ),
216  array( 'DISTINCT rev_user_text', 'rev_user' ),
217  array(
218  $this->db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0',
219  $cond,
220  'page_id = rev_id',
221  ),
222  __METHOD__
223  );
224 
225  foreach ( $res as $row ) {
226  $this->author_list .= "<contributor>" .
227  "<username>" .
228  htmlentities( $row->rev_user_text ) .
229  "</username>" .
230  "<id>" .
231  $row->rev_user .
232  "</id>" .
233  "</contributor>";
234  }
235  $this->author_list .= "</contributors>";
236  wfProfileOut( __METHOD__ );
237  }
238 
244  protected function dumpFrom( $cond = '' ) {
245  wfProfileIn( __METHOD__ );
246  # For logging dumps...
247  if ( $this->history & self::LOGS ) {
248  $where = array( 'user_id = log_user' );
249  # Hide private logs
250  $hideLogs = LogEventsList::getExcludeClause( $this->db );
251  if ( $hideLogs ) {
252  $where[] = $hideLogs;
253  }
254  # Add on any caller specified conditions
255  if ( $cond ) {
256  $where[] = $cond;
257  }
258  # Get logging table name for logging.* clause
259  $logging = $this->db->tableName( 'logging' );
260 
261  if ( $this->buffer == WikiExporter::STREAM ) {
262  $prev = $this->db->bufferResults( false );
263  }
264  $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early
265  try {
266  $result = $this->db->select( array( 'logging', 'user' ),
267  array( "{$logging}.*", 'user_name' ), // grab the user name
268  $where,
269  __METHOD__,
270  array( 'ORDER BY' => 'log_id', 'USE INDEX' => array( 'logging' => 'PRIMARY' ) )
271  );
272  $wrapper = $this->db->resultObject( $result );
273  $this->outputLogStream( $wrapper );
274  if ( $this->buffer == WikiExporter::STREAM ) {
275  $this->db->bufferResults( $prev );
276  }
277  } catch ( Exception $e ) {
278  // Throwing the exception does not reliably free the resultset, and
279  // would also leave the connection in unbuffered mode.
280 
281  // Freeing result
282  try {
283  if ( $wrapper ) {
284  $wrapper->free();
285  }
286  } catch ( Exception $e2 ) {
287  // Already in panic mode -> ignoring $e2 as $e has
288  // higher priority
289  }
290 
291  // Putting database back in previous buffer mode
292  try {
293  if ( $this->buffer == WikiExporter::STREAM ) {
294  $this->db->bufferResults( $prev );
295  }
296  } catch ( Exception $e2 ) {
297  // Already in panic mode -> ignoring $e2 as $e has
298  // higher priority
299  }
300 
301  // Inform caller about problem
302  wfProfileOut( __METHOD__ );
303  throw $e;
304  }
305  # For page dumps...
306  } else {
307  $tables = array( 'page', 'revision' );
308  $opts = array( 'ORDER BY' => 'page_id ASC' );
309  $opts['USE INDEX'] = array();
310  $join = array();
311  if ( is_array( $this->history ) ) {
312  # Time offset/limit for all pages/history...
313  $revJoin = 'page_id=rev_page';
314  # Set time order
315  if ( $this->history['dir'] == 'asc' ) {
316  $op = '>';
317  $opts['ORDER BY'] = 'rev_timestamp ASC';
318  } else {
319  $op = '<';
320  $opts['ORDER BY'] = 'rev_timestamp DESC';
321  }
322  # Set offset
323  if ( !empty( $this->history['offset'] ) ) {
324  $revJoin .= " AND rev_timestamp $op " .
325  $this->db->addQuotes( $this->db->timestamp( $this->history['offset'] ) );
326  }
327  $join['revision'] = array( 'INNER JOIN', $revJoin );
328  # Set query limit
329  if ( !empty( $this->history['limit'] ) ) {
330  $opts['LIMIT'] = intval( $this->history['limit'] );
331  }
332  } elseif ( $this->history & WikiExporter::FULL ) {
333  # Full history dumps...
334  $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page' );
335  } elseif ( $this->history & WikiExporter::CURRENT ) {
336  # Latest revision dumps...
337  if ( $this->list_authors && $cond != '' ) { // List authors, if so desired
338  $this->do_list_authors( $cond );
339  }
340  $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' );
341  } elseif ( $this->history & WikiExporter::STABLE ) {
342  # "Stable" revision dumps...
343  # Default JOIN, to be overridden...
344  $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' );
345  # One, and only one hook should set this, and return false
346  if ( wfRunHooks( 'WikiExporter::dumpStableQuery', array( &$tables, &$opts, &$join ) ) ) {
347  wfProfileOut( __METHOD__ );
348  throw new MWException( __METHOD__ . " given invalid history dump type." );
349  }
350  } elseif ( $this->history & WikiExporter::RANGE ) {
351  # Dump of revisions within a specified range
352  $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page' );
353  $opts['ORDER BY'] = array( 'rev_page ASC', 'rev_id ASC' );
354  } else {
355  # Unknown history specification parameter?
356  wfProfileOut( __METHOD__ );
357  throw new MWException( __METHOD__ . " given invalid history dump type." );
358  }
359  # Query optimization hacks
360  if ( $cond == '' ) {
361  $opts[] = 'STRAIGHT_JOIN';
362  $opts['USE INDEX']['page'] = 'PRIMARY';
363  }
364  # Build text join options
365  if ( $this->text != WikiExporter::STUB ) { // 1-pass
366  $tables[] = 'text';
367  $join['text'] = array( 'INNER JOIN', 'rev_text_id=old_id' );
368  }
369 
370  if ( $this->buffer == WikiExporter::STREAM ) {
371  $prev = $this->db->bufferResults( false );
372  }
373 
374  $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early
375  try {
376  wfRunHooks( 'ModifyExportQuery',
377  array( $this->db, &$tables, &$cond, &$opts, &$join ) );
378 
379  # Do the query!
380  $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join );
381  $wrapper = $this->db->resultObject( $result );
382  # Output dump results
383  $this->outputPageStream( $wrapper );
384 
385  if ( $this->buffer == WikiExporter::STREAM ) {
386  $this->db->bufferResults( $prev );
387  }
388  } catch ( Exception $e ) {
389  // Throwing the exception does not reliably free the resultset, and
390  // would also leave the connection in unbuffered mode.
391 
392  // Freeing result
393  try {
394  if ( $wrapper ) {
395  $wrapper->free();
396  }
397  } catch ( Exception $e2 ) {
398  // Already in panic mode -> ignoring $e2 as $e has
399  // higher priority
400  }
401 
402  // Putting database back in previous buffer mode
403  try {
404  if ( $this->buffer == WikiExporter::STREAM ) {
405  $this->db->bufferResults( $prev );
406  }
407  } catch ( Exception $e2 ) {
408  // Already in panic mode -> ignoring $e2 as $e has
409  // higher priority
410  }
411 
412  // Inform caller about problem
413  throw $e;
414  }
415  }
416  wfProfileOut( __METHOD__ );
417  }
418 
431  protected function outputPageStream( $resultset ) {
432  $last = null;
433  foreach ( $resultset as $row ) {
434  if ( $last === null ||
435  $last->page_namespace != $row->page_namespace ||
436  $last->page_title != $row->page_title ) {
437  if ( $last !== null ) {
438  $output = '';
439  if ( $this->dumpUploads ) {
440  $output .= $this->writer->writeUploads( $last, $this->dumpUploadFileContents );
441  }
442  $output .= $this->writer->closePage();
443  $this->sink->writeClosePage( $output );
444  }
445  $output = $this->writer->openPage( $row );
446  $this->sink->writeOpenPage( $row, $output );
447  $last = $row;
448  }
449  $output = $this->writer->writeRevision( $row );
450  $this->sink->writeRevision( $row, $output );
451  }
452  if ( $last !== null ) {
453  $output = '';
454  if ( $this->dumpUploads ) {
455  $output .= $this->writer->writeUploads( $last, $this->dumpUploadFileContents );
456  }
458  $output .= $this->writer->closePage();
459  $this->sink->writeClosePage( $output );
460  }
461  }
462 
466  protected function outputLogStream( $resultset ) {
467  foreach ( $resultset as $row ) {
468  $output = $this->writer->writeLogItem( $row );
469  $this->sink->writeLogItem( $row, $output );
470  }
471  }
472 }
473 
477 class XmlDumpWriter {
483  function schemaVersion() {
484  wfDeprecated( __METHOD__, '1.20' );
486  }
487 
498  function openStream() {
499  global $wgLanguageCode;
501  return Xml::element( 'mediawiki', array(
502  'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
503  'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
504  'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
505  #TODO: how do we get a new version up there?
506  "http://www.mediawiki.org/xml/export-$ver.xsd",
507  'version' => $ver,
508  'xml:lang' => $wgLanguageCode ),
509  null ) .
510  "\n" .
511  $this->siteInfo();
512  }
513 
517  function siteInfo() {
518  $info = array(
519  $this->sitename(),
520  $this->homelink(),
521  $this->generator(),
522  $this->caseSetting(),
523  $this->namespaces() );
524  return " <siteinfo>\n " .
525  implode( "\n ", $info ) .
526  "\n </siteinfo>\n";
527  }
528 
532  function sitename() {
533  global $wgSitename;
534  return Xml::element( 'sitename', array(), $wgSitename );
535  }
536 
540  function generator() {
541  global $wgVersion;
542  return Xml::element( 'generator', array(), "MediaWiki $wgVersion" );
543  }
544 
548  function homelink() {
549  return Xml::element( 'base', array(), Title::newMainPage()->getCanonicalURL() );
550  }
551 
555  function caseSetting() {
556  global $wgCapitalLinks;
557  // "case-insensitive" option is reserved for future
558  $sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
559  return Xml::element( 'case', array(), $sensitivity );
560  }
561 
565  function namespaces() {
567  $spaces = "<namespaces>\n";
568  foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
569  $spaces .= ' ' .
570  Xml::element( 'namespace',
571  array(
572  'key' => $ns,
573  'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
574  ), $title ) . "\n";
575  }
576  $spaces .= " </namespaces>";
577  return $spaces;
578  }
579 
586  function closeStream() {
587  return "</mediawiki>\n";
588  }
589 
597  public function openPage( $row ) {
598  $out = " <page>\n";
599  $title = Title::makeTitle( $row->page_namespace, $row->page_title );
600  $out .= ' ' . Xml::elementClean( 'title', array(), self::canonicalTitle( $title ) ) . "\n";
601  $out .= ' ' . Xml::element( 'ns', array(), strval( $row->page_namespace ) ) . "\n";
602  $out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
603  if ( $row->page_is_redirect ) {
604  $page = WikiPage::factory( $title );
605  $redirect = $page->getRedirectTarget();
606  if ( $redirect instanceof Title && $redirect->isValidRedirectTarget() ) {
607  $out .= ' ';
608  $out .= Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) );
609  $out .= "\n";
610  }
611  }
612 
613  if ( $row->page_restrictions != '' ) {
614  $out .= ' ' . Xml::element( 'restrictions', array(),
615  strval( $row->page_restrictions ) ) . "\n";
616  }
617 
618  wfRunHooks( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) );
619 
620  return $out;
621  }
622 
629  function closePage() {
630  return " </page>\n";
631  }
632 
641  function writeRevision( $row ) {
642  wfProfileIn( __METHOD__ );
643 
644  $out = " <revision>\n";
645  $out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
646  if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
647  $out .= " " . Xml::element( 'parentid', null, strval( $row->rev_parent_id ) ) . "\n";
648  }
649 
650  $out .= $this->writeTimestamp( $row->rev_timestamp );
651 
652  if ( isset( $row->rev_deleted ) && ( $row->rev_deleted & Revision::DELETED_USER ) ) {
653  $out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
654  } else {
655  $out .= $this->writeContributor( $row->rev_user, $row->rev_user_text );
656  }
657 
658  if ( isset( $row->rev_minor_edit ) && $row->rev_minor_edit ) {
659  $out .= " <minor/>\n";
660  }
661  if ( isset( $row->rev_deleted ) && ( $row->rev_deleted & Revision::DELETED_COMMENT ) ) {
662  $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
663  } elseif ( $row->rev_comment != '' ) {
664  $out .= " " . Xml::elementClean( 'comment', array(), strval( $row->rev_comment ) ) . "\n";
665  }
666 
667  $text = '';
668  if ( isset( $row->rev_deleted ) && ( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
669  $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
670  } elseif ( isset( $row->old_text ) ) {
671  // Raw text from the database may have invalid chars
672  $text = strval( Revision::getRevisionText( $row ) );
673  $out .= " " . Xml::elementClean( 'text',
674  array( 'xml:space' => 'preserve', 'bytes' => intval( $row->rev_len ) ),
675  strval( $text ) ) . "\n";
676  } else {
677  // Stub output
678  $out .= " " . Xml::element( 'text',
679  array( 'id' => $row->rev_text_id, 'bytes' => intval( $row->rev_len ) ),
680  "" ) . "\n";
681  }
682 
683  if ( isset( $row->rev_sha1 )
684  && $row->rev_sha1
685  && !( $row->rev_deleted & Revision::DELETED_TEXT )
686  ) {
687  $out .= " " . Xml::element( 'sha1', null, strval( $row->rev_sha1 ) ) . "\n";
688  } else {
689  $out .= " <sha1/>\n";
690  }
691 
692  if ( isset( $row->rev_content_model ) && !is_null( $row->rev_content_model ) ) {
693  $content_model = strval( $row->rev_content_model );
694  } else {
695  // probably using $wgContentHandlerUseDB = false;
696  // @todo test!
697  $title = Title::makeTitle( $row->page_namespace, $row->page_title );
698  $content_model = ContentHandler::getDefaultModelFor( $title );
699  }
700 
701  $out .= " " . Xml::element( 'model', null, strval( $content_model ) ) . "\n";
702 
703  if ( isset( $row->rev_content_format ) && !is_null( $row->rev_content_format ) ) {
704  $content_format = strval( $row->rev_content_format );
705  } else {
706  // probably using $wgContentHandlerUseDB = false;
707  // @todo test!
708  $content_handler = ContentHandler::getForModelID( $content_model );
709  $content_format = $content_handler->getDefaultFormat();
710  }
711 
712  $out .= " " . Xml::element( 'format', null, strval( $content_format ) ) . "\n";
713 
714  wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
715 
716  $out .= " </revision>\n";
717 
718  wfProfileOut( __METHOD__ );
719  return $out;
720  }
721 
730  function writeLogItem( $row ) {
731  wfProfileIn( __METHOD__ );
732 
733  $out = " <logitem>\n";
734  $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
735 
736  $out .= $this->writeTimestamp( $row->log_timestamp, " " );
737 
738  if ( $row->log_deleted & LogPage::DELETED_USER ) {
739  $out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
740  } else {
741  $out .= $this->writeContributor( $row->log_user, $row->user_name, " " );
742  }
743 
744  if ( $row->log_deleted & LogPage::DELETED_COMMENT ) {
745  $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
746  } elseif ( $row->log_comment != '' ) {
747  $out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
748  }
749 
750  $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
751  $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
752 
753  if ( $row->log_deleted & LogPage::DELETED_ACTION ) {
754  $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
755  } else {
756  $title = Title::makeTitle( $row->log_namespace, $row->log_title );
757  $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
758  $out .= " " . Xml::elementClean( 'params',
759  array( 'xml:space' => 'preserve' ),
760  strval( $row->log_params ) ) . "\n";
761  }
762 
763  $out .= " </logitem>\n";
764 
765  wfProfileOut( __METHOD__ );
766  return $out;
767  }
768 
774  function writeTimestamp( $timestamp, $indent = " " ) {
776  return $indent . Xml::element( 'timestamp', null, $ts ) . "\n";
777  }
778 
785  function writeContributor( $id, $text, $indent = " " ) {
786  $out = $indent . "<contributor>\n";
787  if ( $id || !IP::isValid( $text ) ) {
788  $out .= $indent . " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
789  $out .= $indent . " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
790  } else {
791  $out .= $indent . " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
792  }
793  $out .= $indent . "</contributor>\n";
794  return $out;
795  }
796 
803  function writeUploads( $row, $dumpContents = false ) {
804  if ( $row->page_namespace == NS_FILE ) {
805  $img = wfLocalFile( $row->page_title );
806  if ( $img && $img->exists() ) {
807  $out = '';
808  foreach ( array_reverse( $img->getHistory() ) as $ver ) {
809  $out .= $this->writeUpload( $ver, $dumpContents );
810  }
811  $out .= $this->writeUpload( $img, $dumpContents );
812  return $out;
813  }
814  }
815  return '';
816  }
817 
823  function writeUpload( $file, $dumpContents = false ) {
824  if ( $file->isOld() ) {
825  $archiveName = " " .
826  Xml::element( 'archivename', null, $file->getArchiveName() ) . "\n";
827  } else {
828  $archiveName = '';
829  }
830  if ( $dumpContents ) {
831  $be = $file->getRepo()->getBackend();
832  # Dump file as base64
833  # Uses only XML-safe characters, so does not need escaping
834  # @todo Too bad this loads the contents into memory (script might swap)
835  $contents = ' <contents encoding="base64">' .
836  chunk_split( base64_encode(
837  $be->getFileContents( array( 'src' => $file->getPath() ) ) ) ) .
838  " </contents>\n";
839  } else {
840  $contents = '';
841  }
842  if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
843  $comment = Xml::element( 'comment', array( 'deleted' => 'deleted' ) );
844  } else {
845  $comment = Xml::elementClean( 'comment', null, $file->getDescription() );
846  }
847  return " <upload>\n" .
848  $this->writeTimestamp( $file->getTimestamp() ) .
849  $this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) .
850  " " . $comment . "\n" .
851  " " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
852  $archiveName .
853  " " . Xml::element( 'src', null, $file->getCanonicalURL() ) . "\n" .
854  " " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
855  " " . Xml::element( 'sha1base36', null, $file->getSha1() ) . "\n" .
856  " " . Xml::element( 'rel', null, $file->getRel() ) . "\n" .
857  $contents .
858  " </upload>\n";
859  }
860 
871  public static function canonicalTitle( Title $title ) {
872  if ( $title->isExternal() ) {
873  return $title->getPrefixedText();
874  }
875 
877  $prefix = str_replace( '_', ' ', $wgContLang->getNsText( $title->getNamespace() ) );
878 
879  if ( $prefix !== '' ) {
880  $prefix .= ':';
881  }
882 
883  return $prefix . $title->getText();
884  }
885 }
886 
891 class DumpOutput {
892 
896  function writeOpenStream( $string ) {
897  $this->write( $string );
898  }
899 
903  function writeCloseStream( $string ) {
904  $this->write( $string );
905  }
906 
911  function writeOpenPage( $page, $string ) {
912  $this->write( $string );
913  }
914 
918  function writeClosePage( $string ) {
919  $this->write( $string );
920  }
921 
926  function writeRevision( $rev, $string ) {
927  $this->write( $string );
928  }
929 
934  function writeLogItem( $rev, $string ) {
935  $this->write( $string );
936  }
937 
943  function write( $string ) {
944  print $string;
945  }
946 
954  function closeRenameAndReopen( $newname ) {
955  }
956 
965  function closeAndRename( $newname, $open = false ) {
966  }
967 
973  function getFilenames() {
974  return null;
975  }
976 }
977 
982 class DumpFileOutput extends DumpOutput {
983  protected $handle = false, $filename;
984 
988  function __construct( $file ) {
989  $this->handle = fopen( $file, "wt" );
990  $this->filename = $file;
991  }
992 
996  function writeCloseStream( $string ) {
997  parent::writeCloseStream( $string );
998  if ( $this->handle ) {
999  fclose( $this->handle );
1000  $this->handle = false;
1001  }
1002  }
1003 
1007  function write( $string ) {
1008  fputs( $this->handle, $string );
1009  }
1010 
1014  function closeRenameAndReopen( $newname ) {
1015  $this->closeAndRename( $newname, true );
1016  }
1017 
1022  function renameOrException( $newname ) {
1023  if ( !rename( $this->filename, $newname ) ) {
1024  throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" );
1025  }
1026  }
1027 
1033  function checkRenameArgCount( $newname ) {
1034  if ( is_array( $newname ) ) {
1035  if ( count( $newname ) > 1 ) {
1036  throw new MWException( __METHOD__ . ": passed multiple arguments for rename of single file\n" );
1037  } else {
1038  $newname = $newname[0];
1039  }
1040  }
1041  return $newname;
1042  }
1043 
1048  function closeAndRename( $newname, $open = false ) {
1049  $newname = $this->checkRenameArgCount( $newname );
1050  if ( $newname ) {
1051  if ( $this->handle ) {
1052  fclose( $this->handle );
1053  $this->handle = false;
1054  }
1055  $this->renameOrException( $newname );
1056  if ( $open ) {
1057  $this->handle = fopen( $this->filename, "wt" );
1058  }
1059  }
1060  }
1061 
1065  function getFilenames() {
1066  return $this->filename;
1067  }
1068 }
1069 
1077  protected $command, $filename;
1078  protected $procOpenResource = false;
1079 
1084  function __construct( $command, $file = null ) {
1085  if ( !is_null( $file ) ) {
1086  $command .= " > " . wfEscapeShellArg( $file );
1087  }
1088 
1089  $this->startCommand( $command );
1090  $this->command = $command;
1091  $this->filename = $file;
1092  }
1093 
1097  function writeCloseStream( $string ) {
1098  parent::writeCloseStream( $string );
1099  if ( $this->procOpenResource ) {
1100  proc_close( $this->procOpenResource );
1101  $this->procOpenResource = false;
1102  }
1103  }
1104 
1108  function startCommand( $command ) {
1109  $spec = array(
1110  0 => array( "pipe", "r" ),
1111  );
1112  $pipes = array();
1113  $this->procOpenResource = proc_open( $command, $spec, $pipes );
1114  $this->handle = $pipes[0];
1115  }
1116 
1120  function closeRenameAndReopen( $newname ) {
1121  $this->closeAndRename( $newname, true );
1122  }
1123 
1128  function closeAndRename( $newname, $open = false ) {
1129  $newname = $this->checkRenameArgCount( $newname );
1130  if ( $newname ) {
1131  if ( $this->handle ) {
1132  fclose( $this->handle );
1133  $this->handle = false;
1134  }
1135  if ( $this->procOpenResource ) {
1136  proc_close( $this->procOpenResource );
1137  $this->procOpenResource = false;
1138  }
1139  $this->renameOrException( $newname );
1140  if ( $open ) {
1142  $command .= " > " . wfEscapeShellArg( $this->filename );
1143  $this->startCommand( $command );
1144  }
1145  }
1146  }
1147 
1148 }
1149 
1154 class DumpGZipOutput extends DumpPipeOutput {
1155 
1159  function __construct( $file ) {
1160  parent::__construct( "gzip", $file );
1161  }
1162 }
1163 
1168 class DumpBZip2Output extends DumpPipeOutput {
1169 
1173  function __construct( $file ) {
1174  parent::__construct( "bzip2", $file );
1175  }
1176 }
1177 
1182 class Dump7ZipOutput extends DumpPipeOutput {
1183 
1187  function __construct( $file ) {
1188  $command = $this->setup7zCommand( $file );
1189  parent::__construct( $command );
1190  $this->filename = $file;
1191  }
1192 
1197  function setup7zCommand( $file ) {
1198  $command = "7za a -bd -si " . wfEscapeShellArg( $file );
1199  // Suppress annoying useless crap from p7zip
1200  // Unfortunately this could suppress real error messages too
1201  $command .= ' >' . wfGetNull() . ' 2>&1';
1202  return $command;
1203  }
1204 
1209  function closeAndRename( $newname, $open = false ) {
1210  $newname = $this->checkRenameArgCount( $newname );
1211  if ( $newname ) {
1212  fclose( $this->handle );
1213  proc_close( $this->procOpenResource );
1214  $this->renameOrException( $newname );
1215  if ( $open ) {
1216  $command = $this->setup7zCommand( $this->filename );
1217  $this->startCommand( $command );
1218  }
1219  }
1220  }
1221 }
1222 
1229 class DumpFilter {
1230 
1236  public $sink;
1237 
1241  protected $sendingThisPage;
1242 
1246  function __construct( &$sink ) {
1247  $this->sink =& $sink;
1248  }
1249 
1253  function writeOpenStream( $string ) {
1254  $this->sink->writeOpenStream( $string );
1255  }
1256 
1260  function writeCloseStream( $string ) {
1261  $this->sink->writeCloseStream( $string );
1262  }
1263 
1268  function writeOpenPage( $page, $string ) {
1269  $this->sendingThisPage = $this->pass( $page, $string );
1270  if ( $this->sendingThisPage ) {
1271  $this->sink->writeOpenPage( $page, $string );
1272  }
1273  }
1274 
1278  function writeClosePage( $string ) {
1279  if ( $this->sendingThisPage ) {
1280  $this->sink->writeClosePage( $string );
1281  $this->sendingThisPage = false;
1282  }
1283  }
1284 
1289  function writeRevision( $rev, $string ) {
1290  if ( $this->sendingThisPage ) {
1291  $this->sink->writeRevision( $rev, $string );
1292  }
1293  }
1294 
1299  function writeLogItem( $rev, $string ) {
1300  $this->sink->writeRevision( $rev, $string );
1301  }
1302 
1306  function closeRenameAndReopen( $newname ) {
1307  $this->sink->closeRenameAndReopen( $newname );
1308  }
1309 
1314  function closeAndRename( $newname, $open = false ) {
1315  $this->sink->closeAndRename( $newname, $open );
1316  }
1317 
1321  function getFilenames() {
1322  return $this->sink->getFilenames();
1323  }
1324 
1330  function pass( $page ) {
1331  return true;
1332  }
1333 }
1334 
1339 class DumpNotalkFilter extends DumpFilter {
1340 
1345  function pass( $page ) {
1346  return !MWNamespace::isTalk( $page->page_namespace );
1347  }
1348 }
1349 
1354 class DumpNamespaceFilter extends DumpFilter {
1355  var $invert = false;
1356  var $namespaces = array();
1357 
1363  function __construct( &$sink, $param ) {
1364  parent::__construct( $sink );
1365 
1366  $constants = array(
1367  "NS_MAIN" => NS_MAIN,
1368  "NS_TALK" => NS_TALK,
1369  "NS_USER" => NS_USER,
1370  "NS_USER_TALK" => NS_USER_TALK,
1371  "NS_PROJECT" => NS_PROJECT,
1372  "NS_PROJECT_TALK" => NS_PROJECT_TALK,
1373  "NS_FILE" => NS_FILE,
1374  "NS_FILE_TALK" => NS_FILE_TALK,
1375  "NS_IMAGE" => NS_IMAGE, // NS_IMAGE is an alias for NS_FILE
1376  "NS_IMAGE_TALK" => NS_IMAGE_TALK,
1377  "NS_MEDIAWIKI" => NS_MEDIAWIKI,
1378  "NS_MEDIAWIKI_TALK" => NS_MEDIAWIKI_TALK,
1379  "NS_TEMPLATE" => NS_TEMPLATE,
1380  "NS_TEMPLATE_TALK" => NS_TEMPLATE_TALK,
1381  "NS_HELP" => NS_HELP,
1382  "NS_HELP_TALK" => NS_HELP_TALK,
1383  "NS_CATEGORY" => NS_CATEGORY,
1384  "NS_CATEGORY_TALK" => NS_CATEGORY_TALK );
1385 
1386  if ( $param { 0 } == '!' ) {
1387  $this->invert = true;
1388  $param = substr( $param, 1 );
1389  }
1390 
1391  foreach ( explode( ',', $param ) as $key ) {
1392  $key = trim( $key );
1393  if ( isset( $constants[$key] ) ) {
1394  $ns = $constants[$key];
1395  $this->namespaces[$ns] = true;
1396  } elseif ( is_numeric( $key ) ) {
1397  $ns = intval( $key );
1398  $this->namespaces[$ns] = true;
1399  } else {
1400  throw new MWException( "Unrecognized namespace key '$key'\n" );
1401  }
1402  }
1403  }
1404 
1409  function pass( $page ) {
1410  $match = isset( $this->namespaces[$page->page_namespace] );
1411  return $this->invert xor $match;
1412  }
1413 }
1414 
1419 class DumpLatestFilter extends DumpFilter {
1421 
1426  function writeOpenPage( $page, $string ) {
1427  $this->page = $page;
1428  $this->pageString = $string;
1429  }
1430 
1434  function writeClosePage( $string ) {
1435  if ( $this->rev ) {
1436  $this->sink->writeOpenPage( $this->page, $this->pageString );
1437  $this->sink->writeRevision( $this->rev, $this->revString );
1438  $this->sink->writeClosePage( $string );
1439  }
1440  $this->rev = null;
1441  $this->revString = null;
1442  $this->page = null;
1443  $this->pageString = null;
1444  }
1445 
1450  function writeRevision( $rev, $string ) {
1451  if ( $rev->rev_id == $this->page->page_latest ) {
1452  $this->rev = $rev;
1453  $this->revString = $string;
1454  }
1455  }
1456 }
1457 
1462 class DumpMultiWriter {
1463 
1467  function __construct( $sinks ) {
1468  $this->sinks = $sinks;
1469  $this->count = count( $sinks );
1470  }
1471 
1475  function writeOpenStream( $string ) {
1476  for ( $i = 0; $i < $this->count; $i++ ) {
1477  $this->sinks[$i]->writeOpenStream( $string );
1478  }
1479  }
1480 
1484  function writeCloseStream( $string ) {
1485  for ( $i = 0; $i < $this->count; $i++ ) {
1486  $this->sinks[$i]->writeCloseStream( $string );
1487  }
1488  }
1489 
1494  function writeOpenPage( $page, $string ) {
1495  for ( $i = 0; $i < $this->count; $i++ ) {
1496  $this->sinks[$i]->writeOpenPage( $page, $string );
1497  }
1498  }
1499 
1503  function writeClosePage( $string ) {
1504  for ( $i = 0; $i < $this->count; $i++ ) {
1505  $this->sinks[$i]->writeClosePage( $string );
1506  }
1507  }
1508 
1513  function writeRevision( $rev, $string ) {
1514  for ( $i = 0; $i < $this->count; $i++ ) {
1515  $this->sinks[$i]->writeRevision( $rev, $string );
1516  }
1517  }
1518 
1522  function closeRenameAndReopen( $newnames ) {
1523  $this->closeAndRename( $newnames, true );
1524  }
1525 
1530  function closeAndRename( $newnames, $open = false ) {
1531  for ( $i = 0; $i < $this->count; $i++ ) {
1532  $this->sinks[$i]->closeAndRename( $newnames[$i], $open );
1533  }
1534  }
1535 
1539  function getFilenames() {
1540  $filenames = array();
1541  for ( $i = 0; $i < $this->count; $i++ ) {
1542  $filenames[] = $this->sinks[$i]->getFilenames();
1543  }
1544  return $filenames;
1545  }
1546 
1547 }
1548 
1553 function xmlsafe( $string ) {
1554  wfProfileIn( __FUNCTION__ );
1555 
1561  $string = UtfNormal::cleanUp( $string );
1562 
1563  $string = htmlspecialchars( $string );
1564  wfProfileOut( __FUNCTION__ );
1565  return $string;
1566 }
XmlDumpWriter\openStream
openStream()
Opens the XML output stream's root "<mediawiki>" element.
Definition: Export.php:497
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:67
DumpNamespaceFilter\pass
pass( $page)
Definition: Export.php:1406
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
WikiExporter\schemaVersion
static schemaVersion()
Returns the export schema version.
Definition: Export.php:64
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:311
DumpNamespaceFilter\$namespaces
$namespaces
Definition: Export.php:1353
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
DumpFileOutput\__construct
__construct( $file)
Definition: Export.php:987
DumpPipeOutput\closeRenameAndReopen
closeRenameAndReopen( $newname)
Definition: Export.php:1119
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:66
NS_HELP
const NS_HELP
Definition: Defines.php:91
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
dumpUploads
$dumper dumpUploads
Definition: dumpBackup.php:69
DumpFileOutput\closeRenameAndReopen
closeRenameAndReopen( $newname)
Definition: Export.php:1013
DumpFileOutput\checkRenameArgCount
checkRenameArgCount( $newname)
Definition: Export.php:1032
MWNamespace\isTalk
static isTalk( $index)
Is the given namespace a talk namespace?
Definition: Namespace.php:107
WikiExporter\pagesByRange
pagesByRange( $start, $end)
Dumps a series of page and revision records for those pages in the database falling within the page_i...
Definition: Export.php:131
DumpNamespaceFilter
Dump output filter to include or exclude pages in a given set of namespaces.
Definition: Export.php:1351
DumpPipeOutput\startCommand
startCommand( $command)
Definition: Export.php:1107
NS_IMAGE_TALK
const NS_IMAGE_TALK
Definition: Defines.php:105
$tables
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:815
WikiExporter\revsByRange
revsByRange( $start, $end)
Dumps a series of page and revision records for those pages in the database with revisions falling wi...
Definition: Export.php:146
Dump7ZipOutput\__construct
__construct( $file)
Definition: Export.php:1186
DumpPipeOutput\$filename
$filename
Definition: Export.php:1076
NS_TEMPLATE_TALK
const NS_TEMPLATE_TALK
Definition: Defines.php:90
XmlDumpWriter\openPage
openPage( $row)
Opens a "<page>" section on the output stream, with data from the given database row.
Definition: Export.php:596
WikiExporter\CURRENT
const CURRENT
Definition: Export.php:41
$last
$last
Definition: profileinfo.php:365
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
XmlDumpWriter\siteInfo
siteInfo()
Definition: Export.php:516
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:441
Xml\elementClean
static elementClean( $element, $attribs=array(), $contents='')
Format an XML element as with self::element(), but run text through the $wgContLang->normalize() vali...
Definition: Xml.php:89
DumpFilter\writeLogItem
writeLogItem( $rev, $string)
Definition: Export.php:1296
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
UtfNormal\cleanUp
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C,...
Definition: UtfNormal.php:79
DumpFilter\pass
pass( $page)
Override for page-based filter types.
Definition: Export.php:1327
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
XmlDumpWriter\homelink
homelink()
Definition: Export.php:547
WikiExporter\dumpFrom
dumpFrom( $cond='')
Definition: Export.php:243
WikiExporter\$dumpUploadFileContents
$dumpUploadFileContents
Definition: Export.php:38
DumpPipeOutput\$procOpenResource
$procOpenResource
Definition: Export.php:1077
NS_FILE
const NS_FILE
Definition: Defines.php:85
NS_TEMPLATE
const NS_TEMPLATE
Definition: Defines.php:89
Revision\getRevisionText
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow(),...
Definition: Revision.php:1212
DumpFilter\writeClosePage
writeClosePage( $string)
Definition: Export.php:1275
DumpFilter\writeRevision
writeRevision( $rev, $string)
Definition: Export.php:1286
Dump7ZipOutput\setup7zCommand
setup7zCommand( $file)
Definition: Export.php:1196
WikiExporter\__construct
__construct( $db, $history=WikiExporter::CURRENT, $buffer=WikiExporter::BUFFER, $text=WikiExporter::TEXT)
If using WikiExporter::STREAM to stream a large amount of data, provide a database connection which i...
Definition: Export.php:84
DumpOutput\closeRenameAndReopen
closeRenameAndReopen( $newname)
Close the old file, move it to a specified name, and reopen new file with the old name.
Definition: Export.php:953
DumpFilter\writeOpenPage
writeOpenPage( $page, $string)
Definition: Export.php:1265
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
DumpLatestFilter\$page
$page
Definition: Export.php:1417
DumpNotalkFilter
Simple dump output filter to exclude all talk pages.
Definition: Export.php:1336
DumpOutput\writeOpenStream
writeOpenStream( $string)
Definition: Export.php:895
WikiExporter\allLogs
allLogs()
Definition: Export.php:185
DumpPipeOutput\closeAndRename
closeAndRename( $newname, $open=false)
Definition: Export.php:1127
DumpFileOutput\renameOrException
renameOrException( $newname)
Definition: Export.php:1021
WikiExporter\openStream
openStream()
Definition: Export.php:105
DumpFilter\writeOpenStream
writeOpenStream( $string)
Definition: Export.php:1250
DumpNamespaceFilter\$invert
$invert
Definition: Export.php:1352
DumpFileOutput\write
write( $string)
Definition: Export.php:1006
DumpPipeOutput\writeCloseStream
writeCloseStream( $string)
Definition: Export.php:1096
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
XmlDumpWriter\writeLogItem
writeLogItem( $row)
Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.
Definition: Export.php:729
WikiExporter\STUB
const STUB
Definition: Export.php:50
DumpOutput\writeCloseStream
writeCloseStream( $string)
Definition: Export.php:902
DumpMultiWriter
Base class for output stream; prints to stdout or buffer or wherever.
Definition: Export.php:1459
DumpLatestFilter\writeClosePage
writeClosePage( $string)
Definition: Export.php:1431
ContentHandler\getDefaultModelFor
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
Definition: ContentHandler.php:193
namespaces
to move a page</td >< td > &*You are moving the page across namespaces
Definition: All_system_messages.txt:2677
DumpOutput\getFilenames
getFilenames()
Returns the name of the file or files which are being written to, if there are any.
Definition: Export.php:972
MWException
MediaWiki exception.
Definition: MWException.php:26
$out
$out
Definition: UtfNormalGenerate.php:167
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:53
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
NS_PROJECT
const NS_PROJECT
Definition: Defines.php:83
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
DumpFileOutput\$filename
$filename
Definition: Export.php:982
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:34
WikiExporter\pagesByName
pagesByName( $names)
Definition: Export.php:179
XmlDumpWriter\canonicalTitle
static canonicalTitle(Title $title)
Return prefixed text form of title, but using the content language's canonical namespace.
Definition: Export.php:870
WikiExporter\TEXT
const TEXT
Definition: Export.php:49
DumpOutput\writeRevision
writeRevision( $rev, $string)
Definition: Export.php:925
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:35
XmlDumpWriter\writeContributor
writeContributor( $id, $text, $indent=" ")
Definition: Export.php:784
NS_IMAGE
const NS_IMAGE
NS_IMAGE and NS_IMAGE_TALK are the pre-v1.14 names for NS_FILE and NS_FILE_TALK respectively,...
Definition: Defines.php:104
there
has been added to your &Future changes to this page and its associated Talk page will be listed there
Definition: All_system_messages.txt:357
TS_ISO_8601
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
Definition: GlobalFunctions.php:2448
Title\isValidRedirectTarget
isValidRedirectTarget()
Check if this Title is a valid redirect target.
Definition: Title.php:4789
NS_MEDIAWIKI_TALK
const NS_MEDIAWIKI_TALK
Definition: Defines.php:88
WikiExporter\outputLogStream
outputLogStream( $resultset)
Definition: Export.php:465
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
WikiExporter\$text
$text
Definition: Export.php:54
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
DumpPipeOutput\__construct
__construct( $command, $file=null)
Definition: Export.php:1083
DumpMultiWriter\writeOpenPage
writeOpenPage( $page, $string)
Definition: Export.php:1491
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4001
DumpMultiWriter\__construct
__construct( $sinks)
Definition: Export.php:1464
WikiExporter\closeStream
closeStream()
Definition: Export.php:110
WikiExporter\allPages
allPages()
Dumps a series of page and revision records for all pages in the database, either including complete ...
Definition: Export.php:120
version
Prior to version
Definition: maintenance.txt:1
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
WikiExporter\STABLE
const STABLE
Definition: Export.php:42
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Dump7ZipOutput\closeAndRename
closeAndRename( $newname, $open=false)
Definition: Export.php:1208
$comment
$comment
Definition: importImages.php:107
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:93
DumpOutput
Base class for output stream; prints to stdout or buffer or wherever.
Definition: Export.php:890
XmlDumpWriter\namespaces
namespaces()
Definition: Export.php:564
XmlDumpWriter\closeStream
closeStream()
Closes the output stream with the closing root element.
Definition: Export.php:585
WikiExporter
Definition: Export.php:33
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:33
WikiExporter\$list_authors
$list_authors
Definition: Export.php:34
DumpFileOutput\getFilenames
getFilenames()
Definition: Export.php:1064
DumpLatestFilter
Dump output filter to include only the last revision in each page sequence.
Definition: Export.php:1416
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
function
when a variable name is used in a function
Definition: design.txt:93
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:82
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
writer
An extension writer
Definition: hooks.txt:51
DumpLatestFilter\writeOpenPage
writeOpenPage( $page, $string)
Definition: Export.php:1423
DumpMultiWriter\getFilenames
getFilenames()
Definition: Export.php:1536
DumpLatestFilter\writeRevision
writeRevision( $rev, $string)
Definition: Export.php:1447
WikiExporter\$buffer
$buffer
Definition: Export.php:52
DumpGZipOutput\__construct
__construct( $file)
Definition: Export.php:1158
wfEscapeShellArg
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell,...
Definition: GlobalFunctions.php:2705
WikiExporter\STREAM
const STREAM
Definition: Export.php:47
XmlDumpWriter\caseSetting
caseSetting()
Definition: Export.php:554
DumpFileOutput\$handle
$handle
Definition: Export.php:982
DumpOutput\writeOpenPage
writeOpenPage( $page, $string)
Definition: Export.php:910
up
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set up
Definition: hooks.txt:1679
LogEventsList\getExcludeClause
static getExcludeClause( $db, $audience='public', User $user=null)
SQL clause to skip forbidden log types for this user.
Definition: LogEventsList.php:651
WikiExporter\do_list_authors
do_list_authors( $cond)
Generates the distinct list of authors of an article Not called by default (depends on $this->list_au...
Definition: Export.php:208
XmlDumpWriter\writeUpload
writeUpload( $file, $dumpContents=false)
Definition: Export.php:822
WikiExporter\$dumpUploads
$dumpUploads
Definition: Export.php:37
DumpLatestFilter\$revString
$revString
Definition: Export.php:1417
NS_PROJECT_TALK
const NS_PROJECT_TALK
Definition: Defines.php:84
WikiExporter\FULL
const FULL
Definition: Export.php:40
XmlDumpWriter\writeTimestamp
writeTimestamp( $timestamp, $indent=" ")
Definition: Export.php:773
DumpMultiWriter\writeOpenStream
writeOpenStream( $string)
Definition: Export.php:1472
wfGetNull
wfGetNull()
Get a platform-independent path to the null file, e.g.
Definition: GlobalFunctions.php:3780
WikiExporter\$author_list
$author_list
Definition: Export.php:35
IP\isValid
static isValid( $ip)
Validate an IP address.
Definition: IP.php:108
DumpFilter\closeRenameAndReopen
closeRenameAndReopen( $newname)
Definition: Export.php:1303
DumpMultiWriter\closeAndRename
closeAndRename( $newnames, $open=false)
Definition: Export.php:1527
DumpFilter
Dump output filter class.
Definition: Export.php:1228
XmlDumpWriter\sitename
sitename()
Definition: Export.php:531
DumpFilter\$sink
DumpOutput $sink
FIXME will need to be made protected whenever legacy code is updated.
Definition: Export.php:1234
DumpNotalkFilter\pass
pass( $page)
Definition: Export.php:1342
WikiExporter\RANGE
const RANGE
Definition: Export.php:44
DumpLatestFilter\$pageString
$pageString
Definition: Export.php:1417
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
$count
$count
Definition: UtfNormalTest2.php:96
XmlDumpWriter\writeRevision
writeRevision( $row)
Dumps a "<revision>" section on the output stream, with data filled in from the given database row.
Definition: Export.php:640
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1337
Title
Represents a title within MediaWiki.
Definition: Title.php:35
WikiExporter\setOutputSink
setOutputSink(&$sink)
Set the DumpOutput or DumpFilter object which will receive various row objects and XML output for fil...
Definition: Export.php:101
xmlsafe
xmlsafe( $string)
Definition: Export.php:1550
DumpFilter\closeAndRename
closeAndRename( $newname, $open=false)
Definition: Export.php:1311
WikiExporter\LOGS
const LOGS
Definition: Export.php:43
DumpFileOutput\writeCloseStream
writeCloseStream( $string)
Definition: Export.php:995
NS_HELP_TALK
const NS_HELP_TALK
Definition: Defines.php:92
DumpFilter\$sendingThisPage
bool $sendingThisPage
Definition: Export.php:1238
DumpOutput\closeAndRename
closeAndRename( $newname, $open=false)
Close the old file, and move it to a specified name.
Definition: Export.php:964
$output
& $output
Definition: hooks.txt:375
XmlDumpWriter
Definition: Export.php:476
DumpLatestFilter\$rev
$rev
Definition: Export.php:1417
DumpPipeOutput
Stream outputter to send data to a file via some filter program.
Definition: Export.php:1075
WikiExporter\logsByRange
logsByRange( $start, $end)
Definition: Export.php:193
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
XmlDumpWriter\generator
generator()
Definition: Export.php:539
MWNamespace\isCapitalized
static isCapitalized( $index)
Is the namespace first-letter capitalized?
Definition: Namespace.php:378
DumpNamespaceFilter\__construct
__construct(&$sink, $param)
Definition: Export.php:1360
DumpFileOutput\closeAndRename
closeAndRename( $newname, $open=false)
Definition: Export.php:1047
DumpOutput\write
write( $string)
Override to write to a different stream type.
Definition: Export.php:942
NS_USER
const NS_USER
Definition: Defines.php:81
DumpPipeOutput\$command
$command
Definition: Export.php:1076
DumpGZipOutput
Sends dump output via the gzip compressor.
Definition: Export.php:1153
DumpMultiWriter\writeCloseStream
writeCloseStream( $string)
Definition: Export.php:1481
NS_TALK
const NS_TALK
Definition: Defines.php:80
WikiExporter\pageByTitle
pageByTitle( $title)
Definition: Export.php:157
DumpMultiWriter\closeRenameAndReopen
closeRenameAndReopen( $newnames)
Definition: Export.php:1519
DumpBZip2Output
Sends dump output via the bgzip2 compressor.
Definition: Export.php:1167
XmlDumpWriter\schemaVersion
schemaVersion()
Returns the export schema version.
Definition: Export.php:482
WikiExporter\outputPageStream
outputPageStream( $resultset)
Runs through a query result set dumping page and revision records.
Definition: Export.php:430
DumpFilter\writeCloseStream
writeCloseStream( $string)
Definition: Export.php:1257
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
DumpOutput\writeClosePage
writeClosePage( $string)
Definition: Export.php:917
NS_FILE_TALK
const NS_FILE_TALK
Definition: Defines.php:86
DumpFilter\getFilenames
getFilenames()
Definition: Export.php:1318
WikiExporter\pageByName
pageByName( $name)
Definition: Export.php:167
$e
if( $useReadline) $e
Definition: eval.php:66
NS_CATEGORY_TALK
const NS_CATEGORY_TALK
Definition: Defines.php:94
DumpMultiWriter\writeClosePage
writeClosePage( $string)
Definition: Export.php:1500
DumpBZip2Output\__construct
__construct( $file)
Definition: Export.php:1172
DumpFileOutput
Stream outputter to send data to a file.
Definition: Export.php:981
WikiExporter\$sink
DumpOutput $sink
Definition: Export.php:58
wfLocalFile
wfLocalFile( $title)
Get an object referring to a locally registered file.
Definition: GlobalFunctions.php:3704
DumpMultiWriter\writeRevision
writeRevision( $rev, $string)
Definition: Export.php:1510
$res
$res
Definition: database.txt:21
DumpFilter\__construct
__construct(&$sink)
Definition: Export.php:1243
dumpUploadFileContents
$dumper dumpUploadFileContents
Definition: dumpBackup.php:70
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:65
DumpOutput\writeLogItem
writeLogItem( $rev, $string)
Definition: Export.php:933
XmlDumpWriter\closePage
closePage()
Closes a "<page>" section on the output stream.
Definition: Export.php:628
Dump7ZipOutput
Sends dump output via the p7zip compressor.
Definition: Export.php:1181
XmlDumpWriter\writeUploads
writeUploads( $row, $dumpContents=false)
Warning! This data is potentially inconsistent.
Definition: Export.php:802
WikiExporter\BUFFER
const BUFFER
Definition: Export.php:46
page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk page
Definition: hooks.txt:1956