30require_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' );
65 $cleaned = Sanitizer::decodeCharReferences( $cleaned );
67 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
70 $cleaned = $contLang->checkTitleEncoding( $cleaned );
73 $cleaned = $contLang->normalize( $cleaned );
75 $title = Title::makeTitleSafe(
NS_FILE, $cleaned );
78 $this->
output(
"page $source ($cleaned) is illegal.\n" );
80 if ( $safe ===
false ) {
88 if ( $title->getDBkey() !==
$source ) {
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(
130 [
'page_namespace' =>
NS_FILE,
'page_title' => $name ],
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 ],
188 $this->
output(
"RENAME FAILED, COULD NOT CREATE $dir" );
194 if ( rename( $path, $finalPath ) ) {
197 $this->
error(
"RENAME FAILED" );
205 "\\1$suffix\\2", $name );
210 '/([^' . Title::legalChars() .
']|~)/',
211 [ $this,
'hexChar' ],
214 $test = Title::makeTitleSafe(
NS_FILE, $x );
215 if (
is_null( $test ) || $test->getDBkey() !== $x ) {
216 $this->
error(
"Unable to generate safe title from '$name', got '$x'" );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
Maintenance script to clean up broken, unparseable upload filenames.
appendTitle( $name, $suffix)
__construct()
Default constructor.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
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.
rollbackTransaction(IDatabase $dbw, $fname)
Rollback the transcation on a DB handle.
static singleton()
Get a RepoGroup instance.
Generic class to cleanup a database table.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Allows to change the fields on the form that will be generated $name
require_once RUN_MAINTENANCE_IF_MAIN