Go to the documentation of this file.
30 require_once __DIR__ .
'/cleanupTable.inc';
39 parent::__construct();
40 $this->
addDescription(
'Script to clean up broken, unparseable titles' );
54 &&
$title->getNamespace() == $row->page_namespace
55 &&
$title->getDBkey() === $row->page_title
62 if ( $row->page_namespace ==
NS_FILE && $this->fileExists( $row->page_title ) ) {
63 $this->
output(
"file $row->page_title needs cleanup, please run cleanupImages.php.\n" );
65 } elseif ( is_null(
$title ) ) {
66 $this->
output(
"page $row->page_id ($display) is illegal.\n" );
70 $this->
output(
"page $row->page_id ($display) doesn't match self.\n" );
84 $row =
$dbr->selectRow(
'image', [
'img_name' ], [
'img_name' =>
$name ], __METHOD__ );
86 return $row !==
false;
93 $legal =
'A-Za-z0-9_/\\\\-';
94 $legalized = preg_replace_callback(
"!([^$legal])!",
97 if ( $legalized ==
'.' ) {
100 if ( $legalized ==
'_' ) {
101 $legalized =
'(space)';
103 $legalized =
'Broken/' . $legalized;
106 if ( is_null(
$title ) ) {
107 $clean =
'Broken/id:' . $row->page_id;
108 $this->
output(
"Couldn't legalize; form '$legalized' still invalid; using '$clean'\n" );
110 } elseif (
$title->exists() ) {
111 $clean =
'Broken/id:' . $row->page_id;
112 $this->
output(
"Legalized for '$legalized' exists; using '$clean'\n" );
116 $dest =
$title->getDBkey();
117 if ( $this->dryrun ) {
118 $this->
output(
"DRY RUN: would rename $row->page_id ($row->page_namespace," .
119 "'$row->page_title') to ($row->page_namespace,'$dest')\n" );
121 $this->
output(
"renaming $row->page_id ($row->page_namespace," .
122 "'$row->page_title') to ($row->page_namespace,'$dest')\n" );
124 $dbw->update(
'page',
125 [
'page_title' => $dest ],
126 [
'page_id' => $row->page_id ],
141 $prior =
$title->getPrefixedDBkey();
143 $prior =
$title->getDBkey();
146 # Old cleanupTitles could move articles there. See T25147.
147 $ns = $row->page_namespace;
152 # Namespace which no longer exists. Put the page in the main namespace
153 # since we don't have any idea of the old namespace name. See T70501.
158 $clean =
'Broken/' . $prior;
160 if ( !$verified || $verified->exists() ) {
161 $blah =
"Broken/id:" . $row->page_id;
162 $this->
output(
"Couldn't legalize; form '$clean' exists; using '$blah'\n" );
167 if ( is_null(
$title ) ) {
168 $this->
error(
"Something awry; empty title.",
true );
170 $ns =
$title->getNamespace();
171 $dest =
$title->getDBkey();
173 if ( $this->dryrun ) {
174 $this->
output(
"DRY RUN: would rename $row->page_id ($row->page_namespace," .
175 "'$row->page_title') to ($ns,'$dest')\n" );
177 $this->
output(
"renaming $row->page_id ($row->page_namespace," .
178 "'$row->page_title') to ($ns,'$dest')\n" );
180 $dbw->update(
'page',
182 'page_namespace' => $ns,
183 'page_title' => $dest
185 [
'page_id' => $row->page_id ],
187 MediaWikiServices::getInstance()->getLinkCache()->clear();
__construct()
Default constructor.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Maintenance script to clean up broken, unparseable titles.
static makeName( $ns, $title, $fragment='', $interwiki='', $canonicalNamespace=false)
Make a prefixed DB key from a DB key and a namespace index.
addDescription( $text)
Set the description text.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
require_once RUN_MAINTENANCE_IF_MAIN
Allows to change the fields on the form that will be generated $name
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
namespace and then decline to actually register it file or subcat img or subcat $title
moveInconsistentPage( $row, Title $title)
when a variable name is used in a it is silently declared as a new masking the global
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Generic class to cleanup a database table.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
static exists( $index)
Returns whether the specified namespace exists.
Represents a title within MediaWiki.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
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 MediaWikiServices
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang