24 require_once __DIR__ .
'/Maintenance.php';
37 parent::__construct();
39 'Refresh the externallinks table el_index and el_index_60 from el_to' );
50 return 'externallinks table indexes up to date.';
55 if ( !$dbw->tableExists(
'externallinks', __METHOD__ ) ) {
56 $this->
error(
"externallinks table does not exist" );
59 $this->
output(
"Updating externallinks table index fields\n" );
61 $minmax = $dbw->selectRow(
63 [
'min' =>
'MIN(el_id)',
'max' =>
'MAX(el_id)' ],
70 $start = $minmax->min - 1;
71 $last = (int)$minmax->max;
72 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
73 while ( $start < $last ) {
74 $end = min( $start + $this->mBatchSize, $last );
75 $this->
output(
"el_id $start - $end of $last\n" );
76 $res = $dbw->select(
'externallinks', [
'el_id',
'el_to',
'el_index' ],
82 [
'ORDER BY' =>
'el_id' ]
84 foreach (
$res as $row ) {
87 $dbw->delete(
'externallinks', [
'el_id' => $row->el_id ], __METHOD__ );
91 if ( in_array( $row->el_index, $newIndexes,
true ) ) {
95 if ( count( $newIndexes ) === 1 ) {
96 $newIndex = $newIndexes[0];
100 $newIndex = substr( $row->el_index, 0, strpos( $row->el_index,
':' ) ) .
101 substr( $newIndexes[0], strpos( $newIndexes[0],
':' ) );
103 $dbw->update(
'externallinks',
105 'el_index' => $newIndex,
106 'el_index_60' => substr( $newIndex, 0, 60 ),
108 [
'el_id' => $row->el_id ],
113 $lbFactory->waitForReplication();
116 $this->
output(
"Done, $updated rows updated, $deleted deleted.\n" );
123 require_once RUN_MAINTENANCE_IF_MAIN;
static makeIndexes( $url)
Converts a URL into a format for el_index.
static supportsIDN()
Indicate whether LinkFilter IDN support is available.
const VERSION
Increment this when makeIndexes output changes.
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.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
Maintenance script that refreshes the externallinks table el_index and el_index_60 from el_to.
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
__construct()
Default constructor.
doDBUpdates()
Do the actual work.
getUpdateKey()
Get the update key name to go in the update log table.