Go to the documentation of this file.
30 require_once __DIR__ .
'/Maintenance.php';
45 parent::__construct();
47 $this->mDescription =
'Script to update image metadata records';
50 $this->
addOption(
'force',
'Reload metadata from file even if the metadata looks ok',
false,
false,
'f' );
51 $this->
addOption(
'broken-only',
'Only fix really broken records, leave old but still compatible records alone.' );
52 $this->
addOption(
'verbose',
'Output extra information about each upgraded/non-upgraded file.',
false,
false,
'v' );
53 $this->
addOption(
'start',
'Name of file to start with',
false,
true );
54 $this->
addOption(
'end',
'Name of file to end with',
false,
true );
56 $this->
addOption(
'mime',
'(Inefficient!) Only refresh files with this mime type. Can accept wild-card image/*',
false,
true );
57 $this->
addOption(
'metadata-contains',
'(Inefficient!) Only refresh files where the img_metadata field contains this string. Can be used if its known a specific property was being extracted incorrectly.',
false,
true );
63 $brokenOnly = $this->
hasOption(
'broken-only' );
65 $start = $this->
getOption(
'start',
false );
73 if ( $this->mBatchSize <= 0 ) {
74 $this->
error(
"Batch size is too low...", 12 );
82 if ( $start !==
false ) {
87 'LIMIT' => $this->mBatchSize,
88 'ORDER BY' =>
'img_name ASC',
95 array_merge( $conds, $conds2 ),
100 if (
$res->numRows() > 0 ) {
101 $row1 =
$res->current();
102 $this->
output(
"Processing next {$this->mBatchSize} rows starting with {$row1->img_name}.\n" );
105 $this->
error(
"No images to process.", 4 );
108 foreach (
$res as $row ) {
109 $file = $repo->newFileFromRow( $row );
110 if (
$file->getUpgraded() ) {
113 $newLength = strlen(
$file->getMetadata() );
114 $oldLength = strlen( $row->img_metadata );
115 if ( $newLength < $oldLength - 5 ) {
123 $this->
output(
"Warning: File:{$row->img_name} used to have " .
124 "$oldLength bytes of metadata but now has $newLength bytes.\n" );
126 $this->
output(
"Refreshed File:{$row->img_name}.\n" );
132 $newLength = strlen(
$file->getMetadata() );
133 $oldLength = strlen( $row->img_metadata );
134 if ( $newLength < $oldLength - 5 ) {
136 $this->
output(
"Warning: File:{$row->img_name} used to have " .
137 "$oldLength bytes of metadata but now has $newLength bytes. (forced)\n" );
141 $this->
output(
"Forcibly refreshed File:{$row->img_name}.\n" );
146 $this->
output(
"Skipping File:{$row->img_name}.\n" );
156 $total = $upgraded + $leftAlone;
158 $this->
output(
"\nFinished refreshing file metadata for $total files. $upgraded needed to be refreshed, $leftAlone did not need to be but were refreshed anyways, and $error refreshes were suspicious.\n" );
160 $this->
output(
"\nFinished refreshing file metadata for $total files. $upgraded were refreshed, $leftAlone were already up to date, and $error refreshes were suspicious.\n" );
173 $like = $this->
getOption(
'metadata-contains',
false );
175 if ( $end !==
false ) {
178 if (
$mime !==
false ) {
180 $conds[
'img_major_mime'] = $major;
181 if ( $minor !==
'*' ) {
182 $conds[
'img_minor_mime'] = $minor;
196 global $wgUpdateCompatibleMetadata;
199 $wgUpdateCompatibleMetadata =
false;
201 $wgUpdateCompatibleMetadata =
true;
204 if ( $brokenOnly && $force ) {
205 $this->
error(
'Cannot use --broken-only and --force together. ', 2 );
int $mBatchSize
Batch size.
static singleton()
Get a RepoGroup instance.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string $mime
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
buildLike()
LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match conta...
require_once RUN_MAINTENANCE_IF_MAIN
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
addQuotes( $s)
Adds quotes and backslashes.
select( $table, $vars, $conds='', $fname=__METHOD__, $options=array(), $join_conds=array())
Execute a SELECT query constructed using the various parameters provided.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Database abstraction object.
if(PHP_SAPI !='cli') $file
getOption( $name, $default=null)
Get an option, or return the default.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
hasOption( $name)
Checks to see if a particular param exists.
setBatchSize( $s=0)
Set the batch size.