mirror of
https://github.com/php/php-src.git
synced 2024-12-04 07:14:10 +08:00
- Revert of revision 306542, turns out the semantics of compare() are
different in SplMinHeap and SplMaxHeap.
This commit is contained in:
parent
4a11d76a75
commit
9b698dbcea
@ -229,6 +229,7 @@ static PHP_METHOD(PDO, dbh_constructor)
|
||||
snprintf(alt_dsn, sizeof(alt_dsn), "pdo.dsn.%s", data_source);
|
||||
if (FAILURE == cfg_get_string(alt_dsn, &ini_dsn)) {
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "invalid data source name");
|
||||
zval_dtor(object);
|
||||
ZVAL_NULL(object);
|
||||
return;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ static int spl_ptr_heap_zval_min_cmp(spl_ptr_heap_element a, spl_ptr_heap_elemen
|
||||
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC);
|
||||
if (heap_object->fptr_cmp) {
|
||||
long lval = 0;
|
||||
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)b, (zval *)a, &lval TSRMLS_CC) == FAILURE) {
|
||||
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) {
|
||||
/* exception or call failure */
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
--TEST--
|
||||
Bug #53588 (SplMinHeap bad sorting with custom compare function)
|
||||
--FILE--
|
||||
<?php
|
||||
class MySimpleHeap extends SplMinHeap{
|
||||
public function compare( $value1, $value2 ){
|
||||
return ( $value1 - $value2 );
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new MySimpleHeap();
|
||||
$obj->insert( 8 );
|
||||
$obj->insert( 0 );
|
||||
$obj->insert( 4 );
|
||||
|
||||
foreach( $obj as $number ) {
|
||||
echo $number, "\n";
|
||||
}
|
||||
--EXPECT--
|
||||
0
|
||||
4
|
||||
8
|
||||
|
Loading…
Reference in New Issue
Block a user