Fix bug in OOM avoidance for RepoGroup cache.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 24 Apr 2013 00:17:50 +0000 (17:17 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 24 Apr 2013 00:22:30 +0000 (17:22 -0700)
Change-Id: Ic2e7fb6a9a7207315fd65454d883b84278efafc0

includes/filerepo/file/LocalFile.php

index 8bd8376..325c673 100644 (file)
@@ -1663,11 +1663,11 @@ class LocalFile extends File {
        }
 
        /**
-        * @return bool
+        * @return bool Whether to cache in RepoGroup (this avoids OOMs)
         */
        function isCacheable() {
-               $this->load();
-               return strlen( $this->metadata ) <= self::CACHE_FIELD_MAX_LEN; // avoid OOMs
+               $this->load(); // if loaded from cache, metadata will be null if it didn't fit
+               return $this->metadata !== null && strlen( $this->metadata ) <= self::CACHE_FIELD_MAX_LEN;
        }
 
        /**