diff --git a/hphp/runtime/base/array/policy_array.cpp b/hphp/runtime/base/array/policy_array.cpp index 49c3c8a20..5d7106321 100644 --- a/hphp/runtime/base/array/policy_array.cpp +++ b/hphp/runtime/base/array/policy_array.cpp @@ -481,7 +481,8 @@ ArrayData *ArrayShell::addImpl(K k, const Variant& v, bool copy) { return this; } -ArrayShell *ArrayShell::addLval(int64_t k, Variant*& ret, bool copy) { +template +ArrayShell *ArrayShell::addLvalImpl(K k, Variant*& ret, bool copy) { APILOG << "(" << k << ", " << ret << ", " << copy << ")"; if (copy) { return ArrayShell::copy()->addLval(k, ret, false); @@ -495,10 +496,6 @@ ArrayShell *ArrayShell::addLval(int64_t k, Variant*& ret, bool copy) { return this; } -ArrayShell *ArrayShell::addLval(StringData* k, Variant *&ret, bool copy) { - NOT_IMPLEMENTED(); -} - template ArrayData *ArrayShell::removeImpl(K k, bool copy) { APILOG << "(" << keystr(k) << ", " << copy << ")"; diff --git a/hphp/runtime/base/array/policy_array.h b/hphp/runtime/base/array/policy_array.h index 0d5b8f49a..431471447 100644 --- a/hphp/runtime/base/array/policy_array.h +++ b/hphp/runtime/base/array/policy_array.h @@ -555,10 +555,19 @@ public: * Same semantics as lval(), except with the precondition that the * key doesn't already exist in the array. */ +private: + template + ArrayShell* addLvalImpl(K k, Variant*& ret, bool copy); + +public: virtual ArrayShell *addLval(int64_t k, Variant *&ret, bool copy) - FOLLY_OVERRIDE; + FOLLY_OVERRIDE { + return addLvalImpl(k, ret, copy); + } virtual ArrayShell *addLval(StringData* k, Variant *&ret, bool copy) - FOLLY_OVERRIDE; + FOLLY_OVERRIDE { + return addLvalImpl(k, ret, copy); + } /** * Remove a value at specified key. If "copy" is true, make a copy first diff --git a/hphp/test/slow/apc/1813.php b/hphp/test/slow/apc/1813.php index 871b4a671..3c7bfbbdb 100644 --- a/hphp/test/slow/apc/1813.php +++ b/hphp/test/slow/apc/1813.php @@ -1,6 +1,6 @@ 'tuv'); +$a[] =& $a[0]; +$a[0] = 2; +print_r($a); + +apc_store('table', $a); +$b = apc_fetch('table', $b); +print_r($b); +$b[0] = 3; +print_r($b); + diff --git a/hphp/test/slow/apc/1813.php.expect b/hphp/test/slow/apc/1813.php.expect index 975455ca8..6c94780c3 100644 --- a/hphp/test/slow/apc/1813.php.expect +++ b/hphp/test/slow/apc/1813.php.expect @@ -13,3 +13,21 @@ Array [0] => 3 [1] => 3 ) +Array +( + [xyz] => tuv + [0] => 2 + [1] => 2 +) +Array +( + [xyz] => tuv + [0] => 2 + [1] => 2 +) +Array +( + [xyz] => tuv + [0] => 3 + [1] => 3 +)