Merge "Corrected grammatical error."
[lhc/web/wiklou.git] / includes / cache / localisation / LCStoreCDB.php
index 78a4863..3455470 100644 (file)
@@ -22,9 +22,7 @@ use Cdb\Reader;
 use Cdb\Writer;
 
 /**
- * LCStore implementation which stores data as a collection of CDB files in the
- * directory given by $wgCacheDirectory. If $wgCacheDirectory is not set, this
- * will throw an exception.
+ * LCStore implementation which stores data as a collection of CDB files.
  *
  * Profiling indicates that on Linux, this implementation outperforms MySQL if
  * the directory is on a local filesystem and there is ample kernel cache
@@ -50,11 +48,7 @@ class LCStoreCDB implements LCStore {
        function __construct( $conf = [] ) {
                global $wgCacheDirectory;
 
-               if ( isset( $conf['directory'] ) ) {
-                       $this->directory = $conf['directory'];
-               } else {
-                       $this->directory = $wgCacheDirectory;
-               }
+               $this->directory = $conf['directory'] ?? $wgCacheDirectory;
        }
 
        public function get( $code, $key ) {
@@ -90,11 +84,9 @@ class LCStoreCDB 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}\"" );
-                       }
+               if ( !file_exists( $this->directory ) && !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+                       throw new MWException( "Unable to create the localisation store " .
+                               "directory \"{$this->directory}\"" );
                }
 
                // Close reader to stop permission errors on write