dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "merged master"
[lhc/web/wiklou.git]
/
maintenance
/
rebuildImages.php
diff --git
a/maintenance/rebuildImages.php
b/maintenance/rebuildImages.php
index
15328bf
..
936efd7
100644
(file)
--- a/
maintenance/rebuildImages.php
+++ b/
maintenance/rebuildImages.php
@@
-1,6
+1,6
@@
<?php
/**
<?php
/**
- *
Script to update image metadata records
+ *
Update image metadata records.
*
* Usage: php rebuildImages.php [--missing] [--dry-run]
* Options:
*
* Usage: php rebuildImages.php [--missing] [--dry-run]
* Options:
@@
-27,11
+27,16
@@
*
* @file
* @author Brion Vibber <brion at pobox.com>
*
* @file
* @author Brion Vibber <brion at pobox.com>
- * @ingroup
m
aintenance
+ * @ingroup
M
aintenance
*/
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
*/
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+/**
+ * Maintenance script to update image metadata records.
+ *
+ * @ingroup Maintenance
+ */
class ImageBuilder extends Maintenance {
/**
class ImageBuilder extends Maintenance {
/**
@@
-42,6
+47,10
@@
class ImageBuilder extends Maintenance {
function __construct() {
parent::__construct();
function __construct() {
parent::__construct();
+ global $wgUpdateCompatibleMetadata;
+ //make sure to update old, but compatible img_metadata fields.
+ $wgUpdateCompatibleMetadata = true;
+
$this->mDescription = 'Script to update image metadata records';
$this->addOption( 'missing', 'Check for files without associated database record' );
$this->mDescription = 'Script to update image metadata records';
$this->addOption( 'missing', 'Check for files without associated database record' );
@@
-63,6
+72,9
@@
class ImageBuilder extends Maintenance {
}
}
}
}
+ /**
+ * @return FileRepo
+ */
function getRepo() {
if ( !isset( $this->repo ) ) {
$this->repo = RepoGroup::singleton()->getLocalRepo();
function getRepo() {
if ( !isset( $this->repo ) ) {
$this->repo = RepoGroup::singleton()->getLocalRepo();
@@
-141,8
+153,7
@@
class ImageBuilder extends Maintenance {
}
function buildOldImage() {
}
function buildOldImage() {
- $this->buildTable( 'oldimage', 'oi_archive_name',
- array( $this, 'oldimageCallback' ) );
+ $this->buildTable( 'oldimage', 'oi_archive_name', array( $this, 'oldimageCallback' ) );
}
function oldimageCallback( $row, $copy ) {
}
function oldimageCallback( $row, $copy ) {
@@
-157,42
+168,33
@@
class ImageBuilder extends Maintenance {
}
function crawlMissing() {
}
function crawlMissing() {
- $repo = RepoGroup::singleton()->getLocalRepo();
- $repo->enumFilesInFS( array( $this, 'checkMissingImage' ) );
+ $this->getRepo()->enumFiles( array( $this, 'checkMissingImage' ) );
}
function checkMissingImage( $fullpath ) {
$filename = wfBaseName( $fullpath );
}
function checkMissingImage( $fullpath ) {
$filename = wfBaseName( $fullpath );
- if ( is_dir( $fullpath ) ) {
- return;
- }
- if ( is_link( $fullpath ) ) {
- $this->output( "skipping symlink at $fullpath\n" );
- return;
- }
$row = $this->dbw->selectRow( 'image',
array( 'img_name' ),
array( 'img_name' => $filename ),
__METHOD__ );
$row = $this->dbw->selectRow( 'image',
array( 'img_name' ),
array( 'img_name' => $filename ),
__METHOD__ );
- if ( $row ) {
- // already known, move on
- return;
- } else {
+ if ( !$row ) { // file not registered
$this->addMissingImage( $filename, $fullpath );
}
}
function addMissingImage( $filename, $fullpath ) {
$this->addMissingImage( $filename, $fullpath );
}
}
function addMissingImage( $filename, $fullpath ) {
- $timestamp = $this->dbw->timestamp( filemtime( $fullpath ) );
-
global $wgContLang;
global $wgContLang;
+
+ $timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) );
+
$altname = $wgContLang->checkTitleEncoding( $filename );
if ( $altname != $filename ) {
if ( $this->dryrun ) {
$filename = $altname;
$this->output( "Estimating transcoding... $altname\n" );
} else {
$altname = $wgContLang->checkTitleEncoding( $filename );
if ( $altname != $filename ) {
if ( $this->dryrun ) {
$filename = $altname;
$this->output( "Estimating transcoding... $altname\n" );
} else {
+ # @todo FIXME: create renameFile()
$filename = $this->renameFile( $filename );
}
}
$filename = $this->renameFile( $filename );
}
}
@@
-215,4
+217,4
@@
class ImageBuilder extends Maintenance {
}
$maintClass = 'ImageBuilder';
}
$maintClass = 'ImageBuilder';
-require( RUN_MAINTENANCE_IF_MAIN );
+require
_once
( RUN_MAINTENANCE_IF_MAIN );