From: Tim Starling Date: Sat, 25 Aug 2007 13:54:12 +0000 (+0000) Subject: Update img_sha1 only when it's really needed, instead of in maybeUpgradeRow(). X-Git-Tag: 1.31.0-rc.0~51668 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=6997632877f5326e10de19ef7c40a9cd01476a72;p=lhc%2Fweb%2Fwiklou.git Update img_sha1 only when it's really needed, instead of in maybeUpgradeRow(). --- diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 581142d869..cff948de4e 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -261,8 +261,7 @@ class LocalFile extends File return; } if ( is_null($this->media_type) || - $this->mime == 'image/svg' || - $this->sha1 == '' + $this->mime == 'image/svg' ) { $this->upgradeRow(); $this->upgraded = true; @@ -972,6 +971,19 @@ class LocalFile extends File function getSha1() { $this->load(); + // Initialise now if necessary + if ( $this->sha1 == '' && $this->fileExists ) { + $this->sha1 = File::sha1Base36( $this->getPath() ); + if ( strval( $this->sha1 ) != '' ) { + $dbw = $this->repo->getMasterDB(); + $dbw->update( 'image', + array( 'img_sha1' => $this->sha1 ), + array( 'img_name' => $this->getName() ), + __METHOD__ ); + $this->saveToCache(); + } + } + return $this->sha1; }