Added a separate error message for mkdir failures
[lhc/web/wiklou.git] / includes / cache / ObjectFileCache.php
index d4f98e2..c7ef044 100644 (file)
@@ -1,41 +1,52 @@
 <?php
-class ObjectFileCache extends FileCacheBase {
+/**
+ * Object cache in the file system.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
 
+/**
+ * Object cache in the file system.
+ *
+ * @ingroup Cache
+ */
+class ObjectFileCache extends FileCacheBase {
+       /**
+        * Construct an ObjectFileCache from a key and a type
+        * @param string $key
+        * @param string $type
+        * @return ObjectFileCache
+        */
        public static function newFromKey( $key, $type ) {
                $cache = new self();
 
-               $allowedTypes = self::cacheableTypes();
-               if ( !isset( $allowedTypes[$type] ) ) {
-                       throw new MWException( "Invalid filecache type given." );
-               }
                $cache->mKey = (string)$key;
                $cache->mType = (string)$type;
-               $cache->mExt = $allowedTypes[$cache->mType];
 
                return $cache;
        }
 
-       /*
-        * Get the type => extension mapping
-        * @return array
-        */
-       protected static function cacheableTypes() {
-               return array( 'resources-js' => 'js', 'resources-css' => 'css' );
-       }
-
        /**
         * Get the base file cache directory
         * @return string
         */
        protected function cacheDirectory() {
-               global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
-               if ( $wgFileCacheDirectory ) {
-                       $dir = $wgFileCacheDirectory;
-               } elseif ( $wgCacheDirectory ) {
-                       $dir = "$wgCacheDirectory/object";
-               } else {
-                       throw new MWException( 'Please set $wgCacheDirectory in LocalSettings.php if you wish to use the HTML file cache' );
-               }
-               return $dir;
+               return $this->baseCacheDirectory() . '/object';
        }
 }