diff options
Diffstat (limited to 'includes/CacheDependency.php')
-rw-r--r-- | includes/CacheDependency.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/includes/CacheDependency.php b/includes/CacheDependency.php index 11e70738..74ca2864 100644 --- a/includes/CacheDependency.php +++ b/includes/CacheDependency.php @@ -1,10 +1,11 @@ <?php /** * This class stores an arbitrary value along with its dependencies. - * Users should typically only use DependencyWrapper::getFromCache(), rather - * than instantiating one of these objects directly. + * Users should typically only use DependencyWrapper::getValueFromCache(), + * rather than instantiating one of these objects directly. * @ingroup Cache */ + class DependencyWrapper { var $value; var $deps; @@ -17,9 +18,11 @@ class DependencyWrapper { */ function __construct( $value = false, $deps = array() ) { $this->value = $value; + if ( !is_array( $deps ) ) { $deps = array( $deps ); } + $this->deps = $deps; } @@ -32,6 +35,7 @@ class DependencyWrapper { return true; } } + return false; } @@ -81,6 +85,7 @@ class DependencyWrapper { $callbackParams = array(), $deps = array() ) { $obj = $cache->get( $key ); + if ( is_object( $obj ) && $obj instanceof DependencyWrapper && !$obj->isExpired() ) { $value = $obj->value; } elseif ( $callback ) { @@ -91,6 +96,7 @@ class DependencyWrapper { } else { $value = null; } + return $value; } } @@ -207,6 +213,7 @@ class TitleDependency extends CacheDependency { if ( !isset( $this->titleObj ) ) { $this->titleObj = Title::makeTitle( $this->ns, $this->dbk ); } + return $this->titleObj; } @@ -255,6 +262,7 @@ class TitleListDependency extends CacheDependency { foreach ( $this->getLinkBatch()->data as $ns => $dbks ) { if ( count( $dbks ) > 0 ) { $timestamps[$ns] = array(); + foreach ( $dbks as $dbk => $value ) { $timestamps[$ns][$dbk] = false; } @@ -272,10 +280,11 @@ class TitleListDependency extends CacheDependency { __METHOD__ ); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $timestamps[$row->page_namespace][$row->page_title] = $row->page_touched; } } + return $timestamps; } @@ -297,6 +306,7 @@ class TitleListDependency extends CacheDependency { function isExpired() { $newTimestamps = $this->calculateTimestamps(); + foreach ( $this->timestamps as $ns => $dbks ) { foreach ( $dbks as $dbk => $oldTimestamp ) { $newTimestamp = $newTimestamps[$ns][$dbk]; @@ -319,6 +329,7 @@ class TitleListDependency extends CacheDependency { } } } + return false; } } |