r41164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41163‎ | r41164 | r41165 >
Date:20:22, 22 September 2008
Author:demon
Status:old
Tags:
Comment:
Add ForeignAPIRepo::canCacheThumbs() method. Cleaner interface and removes some code duplication.
Modified paths:
  • /trunk/phase3/includes/filerepo/ForeignAPIFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -112,7 +112,6 @@
113113
114114 function getThumbUrlFromCache( $name, $width, $height ) {
115115 global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory;
116 -;
117116
118117 $key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
119118 if ( $thumbUrl = $wgMemc->get($key) ) {
@@ -135,4 +134,12 @@
136135 return $localUrl;
137136 }
138137 }
 138+
 139+ /**
 140+ * Are we locally caching the thumbnails?
 141+ * @return bool
 142+ */
 143+ public function canCacheThumbs() {
 144+ return ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir );
 145+ }
139146 }
Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php
@@ -31,7 +31,7 @@
3232 }
3333
3434 function transform( $params, $flags = 0 ) {
35 - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
 35+ if ( $this->repo->canCacheThumbs() ) {
3636 $thumbUrl = $this->repo->getThumbUrlFromCache(
3737 $this->getName(),
3838 isset( $params['width'] ) ? $params['width'] : -1,
@@ -110,7 +110,7 @@
111111 */
112112 function getThumbPath( $suffix = '' ) {
113113 $ret = null;
114 - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
 114+ if ( $this->repo->canCacheThumbs() ) {
115115 global $wgUploadDirectory;
116116 $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/';
117117 if ( $suffix ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r41171Redo r41164 with less breakage.demon00:07, 23 September 2008

Status & tagging log