37 parent::__construct();
38 $this->
addDescription(
'Generates list of uploaded files which can be fed to tar or similar.
39By default, outputs relative paths against the parent directory of $wgUploadDirectory.' );
40 $this->
addOption(
'base',
'Set base relative path instead of wiki include root',
false,
true );
41 $this->
addOption(
'local',
'List all local files, used or not. No shared files included' );
42 $this->
addOption(
'used',
'Skip local images that are not used' );
43 $this->
addOption(
'shared',
'Include images used from shared repository' );
48 $this->mBasePath = $this->
getOption(
'base', $IP );
50 $sharedSupplement =
false;
58 $sharedSupplement =
true;
63 $this->fetchLocal( $shared );
65 $this->fetchUsed( $shared );
67 $this->fetchLocal( $shared );
70 if ( $sharedSupplement ) {
71 $this->fetchUsed(
true );
80 private function fetchUsed( $shared ) {
83 $result = $dbr->newSelectQueryBuilder()
84 ->select( [
'il_to',
'img_name' ] )
86 ->from(
'imagelinks' )
87 ->leftJoin(
'image',
null,
'il_to=img_name' )
88 ->caller( __METHOD__ )
91 foreach ( $result as $row ) {
92 $this->outputItem( $row->il_to, $shared );
101 private function fetchLocal( $shared ) {
103 $result = $dbr->newSelectQueryBuilder()
104 ->select(
'img_name' )
106 ->caller( __METHOD__ )
109 foreach ( $result as $row ) {
110 $this->outputItem( $row->img_name, $shared );
114 private function outputItem( $name, $shared ) {
116 if (
$file && $this->filterItem(
$file, $shared ) ) {
117 $filename =
$file->getLocalRefPath();
119 $this->
output(
"$rel\n" );
121 wfDebug( __METHOD__ .
": base file? $name" );
125 private function filterItem(
$file, $shared ) {
126 return $shared ||
$file->isLocal();
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.