28require_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 );
65 $cleaned = Sanitizer::decodeCharReferences( $cleaned );
68 $cleaned =
$wgContLang->checkTitleEncoding( $cleaned );
73 $title = Title::makeTitleSafe(
NS_FILE, $cleaned );
75 if ( is_null( $title ) ) {
76 $this->
output(
"page $source ($cleaned) is illegal.\n" );
78 if ( $safe ===
false ) {
86 if ( $title->getDBkey() !==
$source ) {
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(
128 [
'page_namespace' =>
NS_FILE,
'page_title' => $name ],
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(
208 '/([^' . Title::legalChars() .
']|~)/',
209 [ $this,
'hexChar' ],
212 $test = Title::makeTitleSafe(
NS_FILE, $x );
213 if ( is_null( $test ) || $test->getDBkey() !== $x ) {
214 $this->
error(
"Unable to generate safe title from '$name', got '$x'" );
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.
__construct()
Default constructor.
appendTitle( $name, $suffix)
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.
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.
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
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
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