Go to the documentation of this file.
25 require_once __DIR__ .
'/Maintenance.php';
37 parent::__construct();
39 $this->
addOption(
'delete',
'Perform the deletion' );
40 $this->
addOption(
'filename',
'File name',
false,
true );
41 $this->
addOption(
'filekey',
'File storage key (with extension) or "*"',
true,
true );
46 $this->
output(
"Use --delete to actually confirm this script\n" );
50 $filename = $this->
getOption(
'filename' );
52 if ( $filekey ===
'*' ) {
53 if ( !strlen( $filename ) ) {
54 $this->
error(
"Missing --filename parameter.", 1 );
59 $row = $dbw->selectRow(
'filearchive',
'*',
60 [
'fa_storage_group' =>
'deleted',
'fa_storage_key' => $filekey ],
63 $this->
error(
"No deleted file exists with key '$filekey'.", 1 );
65 $filename = $row->fa_name;
70 if ( $file->exists() ) {
71 $this->
error(
"File '$filename' is still a public file, use the delete form.\n", 1 );
74 $this->
output(
"Purging all thumbnails for file '$filename'..." );
76 $this->
output(
"done.\n" );
81 $this->
output(
"Finding deleted versions of file '$filename'...\n" );
89 $res = $dbw->select(
'filearchive',
'*',
90 [
'fa_name' =>
$name,
'fa_storage_group' =>
'deleted' ],
102 $path = $repo->getZonePath(
'deleted' ) .
'/' . $repo->getDeletedHashPath( $key ) . $key;
104 $status = $repo->getBackend()->delete( [
'src' =>
$path ] );
106 $this->
output(
"Deleted version '$key' ($ts) of file '$name'\n" );
108 $this->
output(
"Failed to delete version '$key' ($ts) of file '$name'\n" );
112 $this->
output(
"Would delete version '{$key}' ({$ts}) of file '$name'\n" );
static singleton()
Get a RepoGroup instance.
getTimestamp()
Return upload timestamp.
addDescription( $text)
Set the description text.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Maintenance script to delete archived (non-current) files from storage.
require_once RUN_MAINTENANCE_IF_MAIN
Allows to change the fields on the form that will be generated $name
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getStorageKey()
Return the FileStore key (overriding base File class)
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
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Class representing a row of the 'filearchive' table.
scrubVersion(ArchivedFile $archivedFile)
getName()
Return the file name.
__construct()
Default constructor.
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
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
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 noclasses just before the function returns a value If you return true
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular param exists.
wfLocalFile( $title)
Get an object referring to a locally registered file.
static newFromRow( $row)
Loads a file object from the filearchive table.
execute()
Do the actual work.