Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311472

Change subject: Remove APC Configuration caching
......................................................................

Remove APC Configuration caching

This is a dangerous microoptimization.

Change-Id: I94fab8822c57381d5a122b4be693d2e1b9c22b57
---
M Core/Configuration.php
1 file changed, 0 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/72/311472/1

diff --git a/Core/Configuration.php b/Core/Configuration.php
index 313dec7..f599160 100644
--- a/Core/Configuration.php
+++ b/Core/Configuration.php
@@ -121,11 +121,6 @@
        public function loadConfigFromPaths( $searchPath ) {
                $paths = $this->expandSearchPathToActual( $searchPath );
 
-               if ( $this->loadConfigFromCache( $paths ) ) {
-                       // Config file loaded, nothing else to do.
-                       return;
-               }
-
                // Reset to empty set.
                $this->options = array();
 
@@ -159,9 +154,6 @@
                                }
                        }
                }
-
-               // Store the configuration to cache, if possible
-               $this->saveConfigToCache( $paths );
        }
 
        /**
@@ -193,80 +185,6 @@
         */
        public function override( $data ) {
                static::treeMerge( $this->options, $data );
-       }
-
-       /**
-        * Loads a configuration file from the cache if it is still valid (ie: 
source files have not
-        * changed)
-        *
-        * TODO: Generalize to any caching backend.
-        *
-        * @param array  $paths    Paths we read from
-        *
-        * @return bool True if the config was loaded successfully.
-        */
-       protected function loadConfigFromCache( $paths ) {
-               if ( !$this->hasApc() ) {
-                       return false;
-               }
-
-               $fileModifiedTimes = array_map( function ( $path ) {
-                       $fileModifiedTimes[] = filemtime( $path );
-               }, $paths );
-
-               // TODO: Cache the config for each installation's paths.
-               $cacheObj = apc_fetch( "smashpig-settings-{$this->viewName}", 
$success );
-
-               if ( !$success
-                       || empty( $cacheObj['configTimes'] )
-                       || empty( $cacheObj['paths'] )
-               ) {
-                       return false;
-               }
-
-               if ( implode( ':', $paths ) === $cacheObj['paths']
-                       && implode( ':', $fileModifiedTimes ) === 
$cacheObj['configTimes']
-               ) {
-                       // The cached values are valid
-                       // TODO: log safely.
-                       $this->options = $cacheObj['values'];
-                       return true;
-               }
-
-               return false;
-       }
-
-       protected function hasApc() {
-               static $useApc = null;
-               if ( $useApc === null ) {
-                       $useApc = extension_loaded( 'apc' );
-               }
-               return $useApc;
-       }
-
-       /**
-        * Saves the loaded configuration to the cache.
-        *
-        * @param array $paths Paths we read from
-        * @param string $node Node name that we're saving to cache
-        */
-       protected function saveConfigToCache( $paths ) {
-               if ( !$this->hasApc() ) {
-                       return;
-               }
-
-               $fileModifiedTimes = array_map( function ( $path ) {
-                       $fileModifiedTimes[] = filemtime( $path );
-               }, $paths );
-
-               apc_store(
-                       "smashpig-settings-{$this->viewName}",
-                       array(
-                                'paths' => implode( ':', $paths ),
-                                'configTimes' => implode( ':', 
$fileModifiedTimes ),
-                                'values' => $this->options,
-                       )
-               );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/311472
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94fab8822c57381d5a122b4be693d2e1b9c22b57
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to