MediaWiki REL1_33
populateExternallinksIndex60.php
Go to the documentation of this file.
1<?php
24require_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";
89require_once RUN_MAINTENANCE_IF_MAIN;
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
int $mBatchSize
Batch size.
output( $out, $channel=null)
Throw some output to the user.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
Maintenance script that populates the el_index_60 field in the externallinks table.
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
getUpdateKey()
Get the update key name to go in the update log table.
$res
Definition database.txt:21
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
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:37
require_once RUN_MAINTENANCE_IF_MAIN
$last
const DB_MASTER
Definition defines.php:26