MediaWiki  1.32.5
populateExternallinksIndex60.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
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 );
39  }
40 
41  protected function getUpdateKey() {
42  return 'populate externallinks.el_index_60';
43  }
44 
45  protected function updateSkippedMessage() {
46  return 'externallinks.el_index_60 already populated.';
47  }
48 
49  protected function doDBUpdates() {
50  $dbw = $this->getDB( DB_MASTER );
51  $this->output( "Populating externallinks.el_index_60...\n" );
52 
53  $count = 0;
54  $start = 0;
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' ],
60  [
61  "el_id > $start",
62  "el_id <= $end",
63  'el_index_60' => '',
64  ],
65  __METHOD__,
66  [ 'ORDER BY' => 'el_id' ]
67  );
68  foreach ( $res as $row ) {
69  $count++;
70  $dbw->update( 'externallinks',
71  [
72  'el_index_60' => substr( $row->el_index, 0, 60 ),
73  ],
74  [
75  'el_id' => $row->el_id,
76  ], __METHOD__
77  );
78  }
80  $start = $end;
81  }
82  $this->output( "Done, $count rows updated.\n" );
83 
84  return true;
85  }
86 }
87 
88 $maintClass = "PopulateExternallinksIndex60";
89 require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance\$mBatchSize
int $mBatchSize
Batch size.
Definition: Maintenance.php:109
PopulateExternallinksIndex60\updateSkippedMessage
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
Definition: populateExternallinksIndex60.php:45
PopulateExternallinksIndex60\doDBUpdates
doDBUpdates()
Do the actual work.
Definition: populateExternallinksIndex60.php:49
$last
$last
Definition: profileinfo.php:419
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:317
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$res
$res
Definition: database.txt:21
wfWaitForSlaves
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Definition: GlobalFunctions.php:2847
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition: Maintenance.php:1679
$maintClass
$maintClass
Definition: populateExternallinksIndex60.php:88
PopulateExternallinksIndex60
Maintenance script that populates the el_index_60 field in the externallinks table.
Definition: populateExternallinksIndex60.php:33
DB_MASTER
const DB_MASTER
Definition: defines.php:26
PopulateExternallinksIndex60\__construct
__construct()
Default constructor.
Definition: populateExternallinksIndex60.php:34
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\getDB
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
Definition: Maintenance.php:1351
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:414
PopulateExternallinksIndex60\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.
Definition: populateExternallinksIndex60.php:41
Maintenance\setBatchSize
setBatchSize( $s=0)
Set the batch size.
Definition: Maintenance.php:355