in_array converted strings to INTs before leading to errors on some architectures.
fixed by making all calls to in_array and array_search STRICT (3d param, bool = true) (thanks to henkjan)
This commit is contained in:
parent
f971cb7866
commit
2b054364fe
@ -638,8 +638,8 @@ class BPlusTree_Node {
|
|||||||
// there are nodes
|
// there are nodes
|
||||||
$keys =& $this->keys;
|
$keys =& $this->keys;
|
||||||
// is the key there already?
|
// is the key there already?
|
||||||
if (in_array($key, $keys)) {
|
if (in_array($key, $keys, true)) {
|
||||||
if (array_search($key, $keys) < $validkeys)
|
if (array_search($key, $keys, true) < $validkeys)
|
||||||
trigger_error("reinsert of node for existing key ($key)",
|
trigger_error("reinsert of node for existing key ($key)",
|
||||||
E_USER_ERROR);
|
E_USER_ERROR);
|
||||||
}
|
}
|
||||||
@ -686,7 +686,7 @@ class BPlusTree_Node {
|
|||||||
$place = 0;
|
$place = 0;
|
||||||
$indexplace = 0;
|
$indexplace = 0;
|
||||||
} else {
|
} else {
|
||||||
$place = array_search($key, $keys);
|
$place = array_search($key, $keys, true);
|
||||||
$indexplace = $place+1;
|
$indexplace = $place+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +795,7 @@ class BPlusTree_Node {
|
|||||||
if (is_null($key))
|
if (is_null($key))
|
||||||
$index = 0;
|
$index = 0;
|
||||||
else
|
else
|
||||||
$index = array_search($key, $this->keys)+1;
|
$index = array_search($key, $this->keys, true)+1;
|
||||||
|
|
||||||
$place = $this->indices[$index];
|
$place = $this->indices[$index];
|
||||||
if ($place<0) {
|
if ($place<0) {
|
||||||
@ -888,8 +888,8 @@ class BPlusTree_Node {
|
|||||||
$this->validkeys = 1;
|
$this->validkeys = 1;
|
||||||
} else {
|
} else {
|
||||||
$place = null;
|
$place = null;
|
||||||
if (in_array($key, $keys)) {
|
if (in_array($key, $keys, true)) {
|
||||||
$place = array_search($key, $keys);
|
$place = array_search($key, $keys, true);
|
||||||
if ($place >= $validkeys) {
|
if ($place >= $validkeys) {
|
||||||
$place = null;
|
$place = null;
|
||||||
}
|
}
|
||||||
@ -1089,11 +1089,11 @@ class BPlusTree_Node {
|
|||||||
function delvalue($key) {
|
function delvalue($key) {
|
||||||
$keys =& $this->keys;
|
$keys =& $this->keys;
|
||||||
$indices =& $this->indices;
|
$indices =& $this->indices;
|
||||||
if (!in_array($key, $keys)) {
|
if (!in_array($key, $keys, true)) {
|
||||||
d($keys);
|
d($keys);
|
||||||
trigger_error ("missing key, can't delete", E_USER_ERROR);
|
trigger_error ("missing key, can't delete", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
$place = array_search($key, $keys);
|
$place = array_search($key, $keys, true);
|
||||||
$validkeys = $this->validkeys;
|
$validkeys = $this->validkeys;
|
||||||
$prev = $validkeys-1;
|
$prev = $validkeys-1;
|
||||||
|
|
||||||
@ -1929,8 +1929,8 @@ class BPlusTree {
|
|||||||
// leaf
|
// leaf
|
||||||
d("FOUND LEAF:");
|
d("FOUND LEAF:");
|
||||||
d($keys);
|
d($keys);
|
||||||
if (!in_array($key, $keys)
|
if (!in_array($key, $keys, true)
|
||||||
|| array_search($key, $keys) >= $validkeys) {
|
|| array_search($key, $keys, true) >= $validkeys) {
|
||||||
$newlength = $this->length +1;
|
$newlength = $this->length +1;
|
||||||
} else {
|
} else {
|
||||||
$newlength = $this->length;
|
$newlength = $this->length;
|
||||||
@ -2241,7 +2241,7 @@ class BPlusTree {
|
|||||||
d($node2->keys);
|
d($node2->keys);
|
||||||
if (in_array(
|
if (in_array(
|
||||||
array_fill(0,$node1->size,''),
|
array_fill(0,$node1->size,''),
|
||||||
array($node1->keys,$node2->keys))
|
array($node1->keys,$node2->keys), true)
|
||||||
) {
|
) {
|
||||||
trigger_error("splitting an empty node!", E_USER_ERROR);
|
trigger_error("splitting an empty node!", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
@ -2404,8 +2404,8 @@ class BPlusWalker {
|
|||||||
if ($keylower==null) {
|
if ($keylower==null) {
|
||||||
$this->node_index = 0;
|
$this->node_index = 0;
|
||||||
$this->valid=1;
|
$this->valid=1;
|
||||||
} elseif (in_array($keylower, $keys) && $this->includelower) {
|
} elseif (in_array($keylower, $keys, true) && $this->includelower) {
|
||||||
$this->node_index = array_search($keylower, $keys);
|
$this->node_index = array_search($keylower, $keys, true);
|
||||||
$index = $this->node_index;
|
$index = $this->node_index;
|
||||||
if ($index<$validkeys) {
|
if ($index<$validkeys) {
|
||||||
$this->valid = 1;
|
$this->valid = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user