Matthias Mullie has uploaded a new change for review.

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

Change subject: Similar to found, introduce got/gotMulti to test if data is in 
local cache
......................................................................

Similar to found, introduce got/gotMulti to test if data is in local cache

Change-Id: I275033231c03ec869dca8a51bbd42abf0279a404
---
M includes/Data/ObjectManager.php
1 file changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/65/111365/1

diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index eddbcec..8f97509 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -390,6 +390,44 @@
                return $retval;
        }
 
+       /**
+        * Returns a boolean true/false if the get()-operation for the given
+        * attributes has already been resolves and doesn't need to query any
+        * outside cache/database.
+        * Determining if a find() has not yet been resolved may be useful so 
that
+        * additional data may be loaded at once.
+        *
+        * @param $id Id to get()
+        * @return bool
+        */
+       public function got( $id ) {
+               return $this->gotMulti( array( $id ) );
+       }
+
+       /**
+        * Returns a boolean true/false if the getMulti()-operation for the 
given
+        * attributes has already been resolves and doesn't need to query any
+        * outside cache/database.
+        * Determining if a find() has not yet been resolved may be useful so 
that
+        * additional data may be loaded at once.
+        *
+        * @param $objectIds Ids to getMulti()
+        * @return bool
+        */
+       public function gotMulti( array $objectIds ) {
+               if ( !$objectIds ) {
+                       return true;
+               }
+
+               $pk = $this->storage->getPrimaryKeyColumns();
+               $queries = array();
+               foreach ( $objectIds as $id ) {
+                       $queries[] = array_combine( $pk, 
ObjectManager::makeArray( $id ) );
+               }
+
+               return $this->foundMulti( $queries );
+       }
+
        protected function getOffsetLimit( $rows, $index, $options ) {
                $limit = isset( $options['limit'] ) ? $options['limit'] : 
$index->getLimit();
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I275033231c03ec869dca8a51bbd42abf0279a404
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to