28 require_once __DIR__ .
'/cleanupTable.inc';
39 'index' =>
'img_name',
40 'callback' =>
'processRow',
44 parent::__construct();
45 $this->
addDescription(
'Script to clean up broken, unparseable upload filenames' );
62 $cleaned = rawurldecode( $cleaned );
68 $cleaned = $wgContLang->checkTitleEncoding( $cleaned );
71 $cleaned = $wgContLang->normalize( $cleaned );
76 $this->
output(
"page $source ($cleaned) is illegal.\n" );
78 if ( $safe ===
false ) {
87 $munged =
$title->getDBkey();
88 $this->
output(
"page $source ($munged) doesn't match self.\n" );
101 if ( $this->dryrun ) {
102 $this->
output(
"DRY RUN: would delete bogus row '$name'\n" );
104 $this->
output(
"deleting bogus row '$name'\n" );
106 $db->delete(
'image',
107 [
'img_name' =>
$name ],
113 if ( !isset( $this->repo ) ) {
117 return $this->repo->getRootDirectory() .
'/' . $this->repo->getHashPath(
$name ) .
$name;
121 return $db->selectField(
'image',
'1', [
'img_name' =>
$name ], __METHOD__ );
125 return $db->selectField(
135 if ( !file_exists(
$path ) ) {
136 $this->
output(
"missing file: $path\n" );
156 while ( $conflict ) {
157 $this->
output(
"Rename conflicts with '$final'...\n" );
163 $finalPath = $this->
filePath( $final );
165 if ( $this->dryrun ) {
166 $this->
output(
"DRY RUN: would rename $path to $finalPath\n" );
168 $this->
output(
"renaming $path to $finalPath\n" );
171 $db->update(
'image',
172 [
'img_name' => $final ],
173 [
'img_name' => $orig ],
175 $db->update(
'oldimage',
176 [
'oi_name' => $final ],
177 [
'oi_name' => $orig ],
180 [
'page_title' => $final ],
181 [
'page_title' => $orig,
'page_namespace' =>
NS_FILE ],
183 $dir = dirname( $finalPath );
184 if ( !file_exists(
$dir ) ) {
186 $this->
output(
"RENAME FAILED, COULD NOT CREATE $dir" );
192 if ( rename(
$path, $finalPath ) ) {
195 $this->
error(
"RENAME FAILED" );
202 return preg_replace(
'/^(.*)(\..*?)$/',
203 "\\1$suffix\\2",
$name );
207 $x = preg_replace_callback(
209 [ $this,
'hexChar' ],
213 if ( is_null( $test ) || $test->getDBkey() !== $x ) {
214 $this->
error(
"Unable to generate safe title from '$name', got '$x'" );
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
wfMkdirParents($dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
rollbackTransaction(IDatabase $dbw, $fname)
Rollback the transcation on a DB handle.
getDB($db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
require_once RUN_MAINTENANCE_IF_MAIN
when a variable name is used in a it is silently declared as a new local masking the global
static decodeCharReferences($text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string...
Generic class to cleanup a database table.
static singleton()
Get a RepoGroup instance.
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
namespace and then decline to actually register it file or subcat img or subcat $title
Maintenance script to clean up broken, unparseable upload filenames.
addDescription($text)
Set the description text.
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.
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 local content language as $wgContLang
static legalChars()
Get a regex character class describing the legal characters in a link.
appendTitle($name, $suffix)
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
Allows to change the fields on the form that will be generated $name