3 * Populates the el_index_60 field in the externallinks table.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup Maintenance
24 require_once __DIR__
. '/Maintenance.php';
27 * Maintenance script that populates the el_index_60 field in the externallinks
30 * @ingroup Maintenance
33 class PopulateExternallinksIndex60
extends LoggedUpdateMaintenance
{
34 public function __construct() {
35 parent
::__construct();
36 $this->addDescription(
37 'Populates the el_index_60 field in the externallinks table' );
38 $this->setBatchSize( 200 );
41 protected function getUpdateKey() {
42 return 'populate externallinks.el_index_60';
45 protected function updateSkippedMessage() {
46 return 'externallinks.el_index_60 already populated.';
49 protected function doDBUpdates() {
50 $dbw = $this->getDB( DB_MASTER
);
51 $this->output( "Populating externallinks.el_index_60...\n" );
55 $last = $dbw->selectField( 'externallinks', 'MAX(el_id)', '', __METHOD__
);
56 while ( $start <= $last ) {
57 $end = $start +
$this->mBatchSize
;
58 $this->output( "el_id $start - $end of $last\n" );
59 $res = $dbw->select( 'externallinks', [ 'el_id', 'el_index' ],
66 [ 'ORDER BY' => 'el_id' ]
68 foreach ( $res as $row ) {
70 $dbw->update( 'externallinks',
72 'el_index_60' => substr( $row->el_index
, 0, 60 ),
75 'el_id' => $row->el_id
,
82 $this->output( "Done, $count rows updated.\n" );
88 $maintClass = "PopulateExternallinksIndex60";
89 require_once RUN_MAINTENANCE_IF_MAIN
;