27 require_once __DIR__ .
'/Maintenance.php';
37 parent::__construct();
38 $this->
addDescription(
'Updates page_restrictions table from old page_restriction column' );
44 if ( !$db->tableExists(
'page_restrictions' ) ) {
45 $this->
error(
"page_restrictions table does not exist",
true );
48 $start = $db->selectField(
'page',
'MIN(page_id)',
false, __METHOD__ );
50 $this->
error(
"Nothing to do.",
true );
52 $end = $db->selectField(
'page',
'MAX(page_id)',
false, __METHOD__ );
55 $end += $this->mBatchSize - 1;
57 $blockEnd = $start + $this->mBatchSize - 1;
58 $encodedExpiry =
'infinity';
59 while ( $blockEnd <= $end ) {
60 $this->
output(
"...doing page_id from $blockStart to $blockEnd\n" );
61 $cond =
"page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !=''";
64 [
'page_id',
'page_namespace',
'page_restrictions' ],
70 $oldRestrictions = [];
71 foreach ( explode(
':', trim( $row->page_restrictions ) )
as $restrict ) {
72 $temp = explode(
'=', trim( $restrict ) );
74 if ( count( $temp ) == 1 && $temp[0] ) {
76 $oldRestrictions[
"edit"] = trim( $temp[0] );
77 $oldRestrictions[
"move"] = trim( $temp[0] );
78 } elseif ( $temp[1] ) {
79 $oldRestrictions[$temp[0]] = trim( $temp[1] );
82 # Clear invalid columns
84 $db->update(
'page', [
'page_restrictions' =>
'' ],
85 [
'page_id' => $row->page_id ], __FUNCTION__ );
86 $this->
output(
"...removed dead page_restrictions column for page {$row->page_id}\n" );
88 # Update restrictions table
89 foreach ( $oldRestrictions
as $action => $restrictions ) {
91 'pr_page' => $row->page_id,
93 'pr_level' => $restrictions,
95 'pr_expiry' => $encodedExpiry
99 # We use insert() and not replace() as Article.php replaces
100 # page_restrictions with '' when protected in the restrictions table
102 $ok = $db->deadlockLoop( [ $db,
'insert' ],
'page_restrictions',
103 $batch, __FUNCTION__, [
'IGNORE' ] );
105 throw new MWException(
"Deadlock loop failed wtf :(" );
108 $blockStart += $this->mBatchSize - 1;
109 $blockEnd += $this->mBatchSize - 1;
112 $this->
output(
"...removing dead rows from page_restrictions\n" );
114 $db->delete(
'page_restrictions', [
'pr_level' =>
'' ] );
123 $this->
output(
"...Done!\n" );
wfWaitForSlaves($ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Maintenance script that updates page_restrictions table from old page_restriction column...
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB($db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
require_once RUN_MAINTENANCE_IF_MAIN
addDescription($text)
Set the description text.
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
output($out, $channel=null)
Throw some output to the user.
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
error($err, $die=0)
Throw an error to the user.
setBatchSize($s=0)
Set the batch size.