MediaWiki
REL1_37
populateExternallinksIndex60.php
Go to the documentation of this file.
1
<?php
24
require_once __DIR__ .
'/Maintenance.php'
;
25
26
use
MediaWiki\MediaWikiServices
;
27
35
class
PopulateExternallinksIndex60
extends
LoggedUpdateMaintenance
{
36
public
function
__construct
() {
37
parent::__construct();
38
$this->
addDescription
(
39
'Populates the el_index_60 field in the externallinks table'
);
40
$this->
setBatchSize
( 200 );
41
}
42
43
protected
function
getUpdateKey
() {
44
return
'populate externallinks.el_index_60'
;
45
}
46
47
protected
function
updateSkippedMessage
() {
48
return
'externallinks.el_index_60 already populated.'
;
49
}
50
51
protected
function
doDBUpdates
() {
52
$dbw = $this->
getDB
(
DB_PRIMARY
);
53
$this->
output
(
"Populating externallinks.el_index_60...\n"
);
54
55
$count = 0;
56
$start = 0;
57
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
58
$last = $dbw->selectField(
'externallinks'
,
'MAX(el_id)'
,
''
, __METHOD__ );
59
while
( $start <= $last ) {
60
$end = $start +
$this->mBatchSize
;
61
$this->
output
(
"el_id $start - $end of $last\n"
);
62
$res
= $dbw->select(
'externallinks'
, [
'el_id'
,
'el_index'
],
63
[
64
"el_id > $start"
,
65
"el_id <= $end"
,
66
'el_index_60'
=>
''
,
67
],
68
__METHOD__,
69
[
'ORDER BY'
=>
'el_id'
]
70
);
71
foreach
(
$res
as $row ) {
72
$count++;
73
$dbw->update(
'externallinks'
,
74
[
75
'el_index_60'
=> substr( $row->el_index, 0, 60 ),
76
],
77
[
78
'el_id'
=> $row->el_id,
79
], __METHOD__
80
);
81
}
82
$lbFactory->waitForReplication();
83
$start = $end;
84
}
85
$this->
output
(
"Done, $count rows updated.\n"
);
86
87
return
true
;
88
}
89
}
90
91
$maintClass
= PopulateExternallinksIndex60::class;
92
require_once RUN_MAINTENANCE_IF_MAIN;
getDB
getDB()
LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition
LoggedUpdateMaintenance.php:26
Maintenance\$mBatchSize
int null $mBatchSize
Batch size.
Definition
Maintenance.php:112
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:435
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:329
Maintenance\setBatchSize
setBatchSize( $s=0)
Definition
Maintenance.php:375
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:190
PopulateExternallinksIndex60
Maintenance script that populates the el_index_60 field in the externallinks table.
Definition
populateExternallinksIndex60.php:35
PopulateExternallinksIndex60\__construct
__construct()
Default constructor.
Definition
populateExternallinksIndex60.php:36
PopulateExternallinksIndex60\doDBUpdates
doDBUpdates()
Do the actual work.
Definition
populateExternallinksIndex60.php:51
PopulateExternallinksIndex60\updateSkippedMessage
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
Definition
populateExternallinksIndex60.php:47
PopulateExternallinksIndex60\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.
Definition
populateExternallinksIndex60.php:43
$maintClass
$maintClass
Definition
populateExternallinksIndex60.php:91
DB_PRIMARY
const DB_PRIMARY
Definition
defines.php:27
$res
$res
Definition
testCompression.php:57
maintenance
populateExternallinksIndex60.php
Generated on Fri Apr 5 2024 23:41:23 for MediaWiki by
1.9.8