[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make refreshImageMetadata not fail completely if it doesn't ...
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/326164 ) Change subject: Make refreshImageMetadata not fail completely if it doesn't like a single file .. Make refreshImageMetadata not fail completely if it doesn't like a single file Change-Id: I1170cf91ba6dea08d35457c9859b8c18482d4aa6 --- M maintenance/refreshImageMetadata.php 1 file changed, 39 insertions(+), 31 deletions(-) Approvals: Bartosz DziewoĆski: Looks good to me, approved jenkins-bot: Verified diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index df4ce56..372c352 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -139,45 +139,53 @@ } foreach ( $res as $row ) { - // LocalFile will upgrade immediately here if obsolete - $file = $repo->newFileFromRow( $row ); - if ( $file->getUpgraded() ) { - // File was upgraded. - $upgraded++; - $newLength = strlen( $file->getMetadata() ); - $oldLength = strlen( $row->img_metadata ); - if ( $newLength < $oldLength - 5 ) { - // If after updating, the metadata is smaller then - // what it was before, that's probably not a good thing - // because we extract more data with time, not less. - // Thus this probably indicates an error of some sort, - // or at the very least is suspicious. Have the - 5 just - // to weed out any inconsequential changes. - $error++; - $this->output( "Warning: File:{$row->img_name} used to have " . - "$oldLength bytes of metadata but now has $newLength bytes.\n" ); - } elseif ( $verbose ) { - $this->output( "Refreshed File:{$row->img_name}.\n" ); - } - } else { - $leftAlone++; - if ( $force ) { - $file->upgradeRow(); + try { + // LocalFile will upgrade immediately here if obsolete + $file = $repo->newFileFromRow( $row ); + if ( $file->getUpgraded() ) { + // File was upgraded. + $upgraded++; $newLength = strlen( $file->getMetadata() ); $oldLength = strlen( $row->img_metadata ); if ( $newLength < $oldLength - 5 ) { + // If after updating, the metadata is smaller then + // what it was before, that's probably not a good thing + // because we extract more data with time, not less. + // Thus this probably indicates an error of some sort, + // or at the very least is suspicious. Have the - 5 just + // to weed out any inconsequential changes. $error++; - $this->output( "Warning: File:{$row->img_name} used to have " . - "$oldLength bytes of metadata but now has $newLength bytes. (forced)\n" ); - } - if ( $verbose ) { - $this->output( "Forcibly refreshed File:{$row->img_name}.\n" ); + $this->output( + "Warning: File:{$row->img_name} used to have " . + "$oldLength bytes of metadata
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make refreshImageMetadata not fail completely if it doesn't ...
Reedy has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/326164 ) Change subject: Make refreshImageMetadata not fail completely if it doesn't like a single file .. Make refreshImageMetadata not fail completely if it doesn't like a single file Change-Id: I1170cf91ba6dea08d35457c9859b8c18482d4aa6 --- M maintenance/refreshImageMetadata.php 1 file changed, 33 insertions(+), 31 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/64/326164/1 diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index df4ce56..021cd64 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -139,45 +139,47 @@ } foreach ( $res as $row ) { - // LocalFile will upgrade immediately here if obsolete - $file = $repo->newFileFromRow( $row ); - if ( $file->getUpgraded() ) { - // File was upgraded. - $upgraded++; - $newLength = strlen( $file->getMetadata() ); - $oldLength = strlen( $row->img_metadata ); - if ( $newLength < $oldLength - 5 ) { - // If after updating, the metadata is smaller then - // what it was before, that's probably not a good thing - // because we extract more data with time, not less. - // Thus this probably indicates an error of some sort, - // or at the very least is suspicious. Have the - 5 just - // to weed out any inconsequential changes. - $error++; - $this->output( "Warning: File:{$row->img_name} used to have " . - "$oldLength bytes of metadata but now has $newLength bytes.\n" ); - } elseif ( $verbose ) { - $this->output( "Refreshed File:{$row->img_name}.\n" ); - } - } else { - $leftAlone++; - if ( $force ) { - $file->upgradeRow(); + try { + // LocalFile will upgrade immediately here if obsolete + $file = $repo->newFileFromRow( $row ); + if ( $file->getUpgraded() ) { + // File was upgraded. + $upgraded++; $newLength = strlen( $file->getMetadata() ); $oldLength = strlen( $row->img_metadata ); if ( $newLength < $oldLength - 5 ) { + // If after updating, the metadata is smaller then + // what it was before, that's probably not a good thing + // because we extract more data with time, not less. + // Thus this probably indicates an error of some sort, + // or at the very least is suspicious. Have the - 5 just + // to weed out any inconsequential changes. $error++; - $this->output( "Warning: File:{$row->img_name} used to have " . - "$oldLength bytes of metadata but now has $newLength bytes. (forced)\n" ); - } - if ( $verbose ) { - $this->output( "Forcibly refreshed File:{$row->img_name}.\n" ); + $this->output( "Warning: File:{$row->img_name} used to have " . "$oldLength bytes of metadata but now has $newLength bytes.\n" ); + } elseif ( $verbose ) { +