65 $this->outputDirectory = $this->getOption(
'output-dir' );
66 $this->prefix = $this->getOption(
'prefix',
'wiki' );
67 $this->startTime = microtime(
true );
69 if ( $this->hasOption(
'parser' ) ) {
70 $this->prefix .=
'-' . $this->getOption(
'parser' );
73 $this->fatalError(
'Parser class configuration temporarily disabled.' );
76 $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [
'steal' =>
true ] );
79 $importer = $this->getServiceContainer()
80 ->getWikiImporterFactory()
83 $importer->setRevisionCallback(
84 [ $this,
'handleRevision' ] );
85 $importer->setNoticeCallback(
static function ( $msg,
$params ) {
89 $importer->doImport();
91 $delta = microtime(
true ) - $this->startTime;
92 $this->error(
"Rendered {$this->count} pages in " . round( $delta, 2 ) .
" seconds " );
94 $this->error( round( $this->count / $delta, 2 ) .
" pages/sec" );
106 $this->error(
"Got bogus revision with null title!" );
110 $display = $title->getPrefixedText();
114 $sanitized = rawurlencode( $display );
115 $filename = sprintf(
"%s/%s-%07d-%s.html",
116 $this->outputDirectory,
120 $this->output( sprintf(
"%s\t%s\n", $filename, $display ) );
123 $options = ParserOptions::newFromUser( $user );
126 $contentRenderer = $this->getServiceContainer()->getContentRenderer();
132 $mutableRev->setId( $rev->
getID() );
134 $output = $contentRenderer->getParserOutput(
135 $content, $title, $mutableRev, $options
138 file_put_contents( $filename,
139 "<!DOCTYPE html>\n" .
140 "<html lang=\"en\" dir=\"ltr\">\n" .
142 "<meta charset=\"UTF-8\" />\n" .
143 "<meta name=\"color-scheme\" content=\"light dark\">" .
144 "<title>" . htmlspecialchars( $display, ENT_COMPAT ) .
"</title>\n" .
148 $output->runOutputPipeline( $options, [] )->getContentHolderText() .