EBernhardson (WMF) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78259
Change subject: LocalBufferedCache make consistent with BagOStuff multiGet
......................................................................
LocalBufferedCache make consistent with BagOStuff multiGet
Makes LocalBufferedCache treat unfound results the same as BagOStuff does in a
multiGet situation
Change-Id: I26baac260b210dc08be5dda6921e595784088c48
---
M includes/Data/ObjectManager.php
M includes/Model/AbstractRevision.php
2 files changed, 16 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/59/78259/1
diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 8a26128..4311aa5 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -1037,11 +1037,6 @@
return self::compare( $a, $b, $this->keys, $this->strict );
}
- public function setStrict() {
- $this->strict = true;
- return $this;
- }
-
static public function compare( $a, $b, $keys, $strict = false ) {
$key = array_shift( $keys );
if ( !isset( $a[$key] ) ) {
@@ -1057,6 +1052,7 @@
}
// Untested method of handling duplicate requests for the same data
+// Preserves any BagOStuff semantics like BufferedCache does
class LocalBufferedCache extends BufferedCache {
protected $internal = array();
@@ -1071,7 +1067,10 @@
$found = array();
foreach ( $keys as $idx => $key ) {
if ( array_key_exists( $key, $this->internal ) ) {
- $found[$key] = $this->internal[$key];
+ // BagOStuff::multiGet doesn't return the
unfound keys
+ if ( $this->internal[$key] !== false ) {
+ $found[$key] = $this->internal[$key];
+ }
unset( $keys[$idx] );
}
}
@@ -1079,6 +1078,11 @@
$flipped = array_flip( $keys );
foreach ( parent::getMulti( $keys ) as $key => $value )
{
$this->internal[$key] = $found[$key] = $value;
+ unset( $keys[$flipped[$key]] );
+ }
+ // BagOStuff::multiGet doesn't return the unfound keys,
but we cache the result
+ foreach ( $keys as $key ) {
+ $this->internal[$key] = false;
}
}
return $found;
@@ -1096,7 +1100,7 @@
);
// speculative ... could cause a ton of bugs due to
normal assumptions
// how to do this reasonably?
- if ( !isset( $this->internal[$key] ) ) {
+ if ( !array_key_exists( $key, $this->internal ) ||
$this->internal[$key] === false ) {
$this->internal[$key] = $value;
}
}
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index 335f303..6301785 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -64,9 +64,12 @@
);
}
+ /**
+ * NOTE: No guarantee is made here regarding if $this is the newest
revision. Validation
+ * must happen externally. DB *will* throw an exception if this
attempts to write to db
+ * and it is not the most recent revision.
+ */
public function newNullRevision( User $user ) {
- // TODO: how do we know this is the latest revision? we dont ...
- // basically, this is very very wrong :-(
$obj = clone $this;
$obj->revId = UUID::create();
$obj->userId = $user->getId();
--
To view, visit https://gerrit.wikimedia.org/r/78259
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I26baac260b210dc08be5dda6921e595784088c48
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits