Go to the documentation of this file.
30 require_once __DIR__ .
'/cleanupTable.inc';
41 'index' =>
'img_name',
42 'callback' =>
'processRow',
46 parent::__construct();
47 $this->
addDescription(
'Script to clean up broken, unparseable upload filenames' );
62 $cleaned = rawurldecode( $cleaned );
65 $cleaned = Sanitizer::decodeCharReferences( $cleaned );
67 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
70 $cleaned = $contLang->checkTitleEncoding( $cleaned );
73 $cleaned = $contLang->normalize( $cleaned );
78 $this->
output(
"page $source ($cleaned) is illegal.\n" );
80 if ( $safe ===
false ) {
89 $munged =
$title->getDBkey();
90 $this->
output(
"page $source ($munged) doesn't match self.\n" );
103 if ( $this->dryrun ) {
104 $this->
output(
"DRY RUN: would delete bogus row '$name'\n" );
106 $this->
output(
"deleting bogus row '$name'\n" );
108 $db->delete(
'image',
109 [
'img_name' =>
$name ],
115 if ( !isset( $this->repo ) ) {
119 return $this->repo->getRootDirectory() .
'/' . $this->repo->getHashPath(
$name ) .
$name;
123 return $db->selectField(
'image',
'1', [
'img_name' =>
$name ], __METHOD__ );
127 return $db->selectField(
137 if ( !file_exists(
$path ) ) {
138 $this->
output(
"missing file: $path\n" );
158 while ( $conflict ) {
159 $this->
output(
"Rename conflicts with '$final'...\n" );
165 $finalPath = $this->
filePath( $final );
167 if ( $this->dryrun ) {
168 $this->
output(
"DRY RUN: would rename $path to $finalPath\n" );
170 $this->
output(
"renaming $path to $finalPath\n" );
173 $db->update(
'image',
174 [
'img_name' => $final ],
175 [
'img_name' => $orig ],
177 $db->update(
'oldimage',
178 [
'oi_name' => $final ],
179 [
'oi_name' => $orig ],
182 [
'page_title' => $final ],
183 [
'page_title' => $orig,
'page_namespace' =>
NS_FILE ],
185 $dir = dirname( $finalPath );
186 if ( !file_exists( $dir ) ) {
188 $this->
output(
"RENAME FAILED, COULD NOT CREATE $dir" );
194 if ( rename(
$path, $finalPath ) ) {
197 $this->
error(
"RENAME FAILED" );
204 return preg_replace(
'/^(.*)(\..*?)$/',
205 "\\1$suffix\\2",
$name );
209 $x = preg_replace_callback(
211 [ $this,
'hexChar' ],
215 if ( is_null( $test ) || $test->getDBkey() !== $x ) {
216 $this->
error(
"Unable to generate safe title from '$name', got '$x'" );
static singleton()
Get a RepoGroup instance.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
addDescription( $text)
Set the description text.
require_once RUN_MAINTENANCE_IF_MAIN
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
rollbackTransaction(IDatabase $dbw, $fname)
Rollback the transcation on a DB handle.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
namespace and then decline to actually register it file or subcat img or subcat $title
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
Allows to change the fields on the form that will be generated $name
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.
Maintenance script to clean up broken, unparseable upload filenames.
__construct()
Default constructor.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
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.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
static legalChars()
Get a regex character class describing the legal characters in a link.
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
appendTitle( $name, $suffix)