Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/129174
Change subject: Handle empty keys in MWMemcached
......................................................................
Handle empty keys in MWMemcached
Also attempt to avoid implicit array to string conversions
Bug: 64287
Change-Id: Iedfec96286212577a181b83957cdc4545be206d2
---
M includes/objectcache/MemcachedClient.php
1 file changed, 13 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/74/129174/1
diff --git a/includes/objectcache/MemcachedClient.php
b/includes/objectcache/MemcachedClient.php
index bc59c6f..9e61961 100644
--- a/includes/objectcache/MemcachedClient.php
+++ b/includes/objectcache/MemcachedClient.php
@@ -414,8 +414,16 @@
public function get( $key, &$casToken = null ) {
wfProfileIn( __METHOD__ );
+ $realkey = is_array( $key ) ? $key[1] : $key;
+
+ if ( strval( $realkey ) === '' ) {
+ $this->_debugprint( "got invalid key\n" );
+ wfProfileOut();
+ throw new MWException( "Got empty key" );
+ }
+
if ( $this->_debug ) {
- $this->_debugprint( "get($key)\n" );
+ $this->_debugprint( "get($realkey)\n" );
}
if ( !$this->_active ) {
@@ -423,6 +431,7 @@
return false;
}
+ // Does this need the array?
$sock = $this->get_sock( $key );
if ( !is_resource( $sock ) ) {
@@ -430,14 +439,13 @@
return false;
}
- $key = is_array( $key ) ? $key[1] : $key;
if ( isset( $this->stats['get'] ) ) {
$this->stats['get']++;
} else {
$this->stats['get'] = 1;
}
- $cmd = "gets $key\r\n";
+ $cmd = "gets $realkey\r\n";
if ( !$this->_fwrite( $sock, $cmd ) ) {
wfProfileOut( __METHOD__ );
return false;
@@ -453,8 +461,8 @@
}
$value = false;
- if ( isset( $val[$key] ) ) {
- $value = $val[$key];
+ if ( isset( $val[$realkey] ) ) {
+ $value = $val[$realkey];
}
wfProfileOut( __METHOD__ );
return $value;
--
To view, visit https://gerrit.wikimedia.org/r/129174
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iedfec96286212577a181b83957cdc4545be206d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits