r25133 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25132‎ | r25133 | r25134 >
Date:13:54, 25 August 2007
Author:tstarling
Status:old
Tags:
Comment:
Update img_sha1 only when it's really needed, instead of in maybeUpgradeRow().
Modified paths:
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -261,8 +261,7 @@
262262 return;
263263 }
264264 if ( is_null($this->media_type) ||
265 - $this->mime == 'image/svg' ||
266 - $this->sha1 == ''
 265+ $this->mime == 'image/svg'
267266 ) {
268267 $this->upgradeRow();
269268 $this->upgraded = true;
@@ -972,6 +971,19 @@
973972
974973 function getSha1() {
975974 $this->load();
 975+ // Initialise now if necessary
 976+ if ( $this->sha1 == '' && $this->fileExists ) {
 977+ $this->sha1 = File::sha1Base36( $this->getPath() );
 978+ if ( strval( $this->sha1 ) != '' ) {
 979+ $dbw = $this->repo->getMasterDB();
 980+ $dbw->update( 'image',
 981+ array( 'img_sha1' => $this->sha1 ),
 982+ array( 'img_name' => $this->getName() ),
 983+ __METHOD__ );
 984+ $this->saveToCache();
 985+ }
 986+ }
 987+
976988 return $this->sha1;
977989 }
978990

Follow-up revisions

RevisionCommit summaryAuthorDate
r25223Merged revisions 25126-25214 via svnmerge from...david07:39, 28 August 2007

Status & tagging log