28 $maintenanceScript = __DIR__ .
"/../../maintenance/Maintenance.php";
29 if ( file_exists( $maintenanceScript ) ) {
30 require_once $maintenanceScript;
36 $maintenanceScript = __DIR__ .
"/Maintenance.php";
37 if ( file_exists( $maintenanceScript ) ) {
38 require_once $maintenanceScript;
42 die(
"FATAL: Could not locate Maintenance.php.\n" .
43 "You may want to create a symbolic link named Maintenance.php in this directory\n" .
44 "which points to <YOUR_MEDIAWIKI_ROOT_IN_FILESYSTEM>/extensions/Maintenance.php\n" .
45 "Ex.: ln -s /var/www/wiki/maintenance/Maintenance.php\n\n");
49 require_once( __DIR__ .
"/includes/Extension.php" );
60 class Cli extends \Maintenance {
65 parent::__construct();
66 $this->addDescription(
"Iterates over wiki pages and automatically adds links to other pages.");
76 "page name to process",
104 public function execute() {
113 if ( $this->hasOption(
'page') ) {
114 if ( !$this->hasOption(
'start' ) ) {
118 $this->error(
'FATAL: Must not use --start option with --page option.', 2 );
122 $startIndex = intval( $this->getOption(
'start', 0 ) );
123 if ( $startIndex < 0 ) {
124 $this->error(
'FATAL: Start index must be 0 or greater.', 1 );
126 $this->allPages( $startIndex );
135 $pageName = strval( $this->getOption(
'page' ) );
136 $this->output(
"Processing single page: '$pageName'\n" );
137 $title = \Title::newFromText( $pageName );
138 $success = Extension::processPage( $title, \RequestContext::getMain() );
140 $this->output(
"Finished.\n" );
143 $this->error(
'FATAL: There is no such page.', 3 );
157 $dbr = $this->getDB( DB_SLAVE );
158 $namespacesClause = str_replace(
'_',
' ',
'(' . implode(
', ', $config->sourceNamespaces ) .
')' );
161 array(
'page_title',
'page_namespace' ),
163 'page_namespace IN ' . $namespacesClause,
167 'LIMIT' => 999999999,
171 $numPages = $res->numRows();
172 $context = \RequestContext::getMain();
173 $this->output(
"Processing ${numPages} pages, starting at index ${index}...\n" );
175 foreach ( $res as $row ) {
177 $title = \Title::makeTitleSafe( $row->page_namespace, $row->page_title );
178 $this->output( sprintf(
"\rPage #%d (%02.0f%%) ", $index, $index / $numPages * 100 ) );
179 Extension::processPage( $title, $context );
182 $this->output(
"\rFinished. \n" );
186 $maintClass =
'LinkTitles\Cli';
187 if( defined(
'RUN_MAINTENANCE_IF_MAIN') ) {
188 require_once( RUN_MAINTENANCE_IF_MAIN );
190 require_once( DO_MAINTENANCE );
allPages($index=0)
Process all pages in the Wiki.
singlePage()
Processes a single page.
Core class of the maintanance script.
Holds LinkTitles configuration.
The LinkTitles class holds configuration for the LinkTitles extension.
__construct()
Constructor.