LCStoreStaticArray: create cache directory when it doesn't exist
authorEdward Chernenko <edwardspec@gmail.com>
Mon, 25 Jun 2018 15:40:25 +0000 (18:40 +0300)
committerEdward Chernenko <edwardspec@gmail.com>
Mon, 25 Jun 2018 15:40:25 +0000 (18:40 +0300)
Array store (LCStoreStaticArray) should behave as standard LCStoreCDB,
creating the target directory when it doesn't exist.

This fixes unexpected "No such file or directory" errors when
replacing 'files' with 'array' in $wgLocalisationCacheConf['store'].

Change-Id: Ie49cf03ca93ac47fc98665de36e6207bef287193

includes/cache/localisation/LCStoreStaticArray.php

index 602c0ac..38700b8 100644 (file)
@@ -47,6 +47,13 @@ class LCStoreStaticArray implements LCStore {
        }
 
        public function startWrite( $code ) {
+               if ( !file_exists( $this->directory ) ) {
+                       if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+                               throw new MWException( "Unable to create the localisation store " .
+                                       "directory \"{$this->directory}\"" );
+                       }
+               }
+
                $this->currentLang = $code;
                $this->fname = $this->directory . '/' . $code . '.l10n.php';
                $this->data[$code] = [];