24 require_once __DIR__ .
'/Maintenance.php';
33 parent::__construct();
35 $this->
addOption(
'lastUpdatedId',
"Highest page_id with updated links",
false,
true );
39 return 'populate *_from_namespace';
43 return '*_from_namespace column of backlink tables already populated.';
49 $this->
output(
"Updating *_from_namespace fields in links tables.\n" );
51 $start = $this->
getOption(
'lastUpdatedId' );
53 $start = $db->newSelectQueryBuilder()
54 ->select(
'MIN(page_id)' )
56 ->caller( __METHOD__ )->fetchField();
59 $this->
output(
"Nothing to do." );
62 $end = $db->newSelectQueryBuilder()
63 ->select(
'MAX(page_id)' )
65 ->caller( __METHOD__ )->fetchField();
69 $end += $batchSize - 1;
71 $blockEnd = $start + $batchSize - 1;
72 while ( $blockEnd <= $end ) {
73 $this->
output(
"...doing page_id from $blockStart to $blockEnd\n" );
74 $res = $db->newSelectQueryBuilder()
75 ->select( [
'page_id',
'page_namespace' ] )
77 ->where(
"page_id BETWEEN " . (
int)$blockStart .
" AND " . (
int)$blockEnd )
78 ->caller( __METHOD__ )->fetchResultSet();
79 foreach ( $res as $row ) {
80 $db->update(
'pagelinks',
81 [
'pl_from_namespace' => $row->page_namespace ],
82 [
'pl_from' => $row->page_id ],
85 $db->update(
'templatelinks',
86 [
'tl_from_namespace' => $row->page_namespace ],
87 [
'tl_from' => $row->page_id ],
90 $db->update(
'imagelinks',
91 [
'il_from_namespace' => $row->page_namespace ],
92 [
'il_from' => $row->page_id ],
96 $blockStart += $batchSize - 1;
97 $blockEnd += $batchSize - 1;
105 require_once RUN_MAINTENANCE_IF_MAIN;
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
output( $out, $channel=null)
Throw some output to the user.
waitForReplication()
Wait for replica DBs to catch up.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
Maintenance script to populate *_from_namespace fields.
getUpdateKey()
Get the update key name to go in the update log table.
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
doDBUpdates()
Do the actual work.
__construct()
Default constructor.