27require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
42 $this->
addDescription(
'Generates list of uploaded files which can be fed to tar or similar.
43By default, outputs relative paths against the parent directory of $wgUploadDirectory.' );
44 $this->
addOption(
'base',
'Set base relative path instead of wiki include root',
false,
true );
45 $this->
addOption(
'local',
'List all local files, used or not. No shared files included' );
46 $this->
addOption(
'used',
'Skip local images that are not used' );
47 $this->
addOption(
'shared',
'Include images used from shared repository' );
52 $this->mBasePath = $this->
getOption(
'base', $IP );
54 $sharedSupplement =
false;
62 $sharedSupplement =
true;
67 $this->fetchLocal( $shared );
69 $this->fetchUsed( $shared );
71 $this->fetchLocal( $shared );
74 if ( $sharedSupplement ) {
75 $this->fetchUsed(
true );
84 private function fetchUsed( $shared ) {
87 $result = $dbr->newSelectQueryBuilder()
88 ->select( [
'il_to',
'img_name' ] )
90 ->from(
'imagelinks' )
91 ->leftJoin(
'image',
null,
'il_to=img_name' )
92 ->caller( __METHOD__ )
95 foreach ( $result as $row ) {
96 $this->outputItem( $row->il_to, $shared );
105 private function fetchLocal( $shared ) {
107 $result = $dbr->newSelectQueryBuilder()
108 ->select(
'img_name' )
110 ->caller( __METHOD__ )
113 foreach ( $result as $row ) {
114 $this->outputItem( $row->img_name, $shared );
118 private function outputItem( $name, $shared ) {
120 if ( $file && $this->filterItem( $file, $shared ) ) {
121 $filename = $file->getLocalRefPath();
123 $this->
output(
"$rel\n" );
125 wfDebug( __METHOD__ .
": base file? $name" );
129 private function filterItem( $file, $shared ) {
130 return $shared || $file->isLocal();
136require_once RUN_MAINTENANCE_IF_MAIN;
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfRelativePath( $path, $from)
Generate a relative path name to the given file.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Maintenance script to dump a the list of files uploaded, for feeding to tar or similar.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.