(array) casts are *not* affected. They will continue to return either the
wrapped array, or the ArrayObject properties, depending on whether the
STD_PROP_LIST flag is used.
+ . SplPriorityQueue::setExtractFlags() will throw an exception if zero is
+ passed. Previously this would generate a recoverable fatal error on the
+ next extraction operation.
========================================
2. New Features
}
/* }}} */
-static int spl_pqueue_extract_helper(zval *result, zval *value, int flags) /* {{{ */
+static void spl_pqueue_extract_helper(zval *result, zval *value, int flags) /* {{{ */
{
spl_pqueue_elem *elem = Z_PTR_P(value);
if ((flags & SPL_PQUEUE_EXTR_BOTH) == SPL_PQUEUE_EXTR_BOTH) {
array_init(result);
add_assoc_zval_ex(result, "data", sizeof("data") - 1, &elem->data);
add_assoc_zval_ex(result, "priority", sizeof("priority") - 1, &elem->priority);
- return SUCCESS;
+ return;
}
if (flags & SPL_PQUEUE_EXTR_DATA) {
ZVAL_COPY(result, &elem->data);
- return SUCCESS;
+ return;
}
if (flags & SPL_PQUEUE_EXTR_PRIORITY) {
ZVAL_COPY(result, &elem->priority);
- return SUCCESS;
+ return;
}
- return FAILURE;
+ ZEND_ASSERT(0);
}
/* }}} */
return;
}
- if (spl_pqueue_extract_helper(return_value, &value, intern->flags) == FAILURE) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- spl_ptr_heap_pqueue_elem_dtor(&value);
- return;
- }
+ spl_pqueue_extract_helper(return_value, &value, intern->flags);
}
/* }}} */
return;
}
- if (spl_pqueue_extract_helper(return_value, value, intern->flags) == FAILURE) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- }
+ spl_pqueue_extract_helper(return_value, value, intern->flags);
}
/* }}} */
return;
}
- intern = Z_SPLHEAP_P(ZEND_THIS);
-
- intern->flags = value & SPL_PQUEUE_EXTR_MASK;
+ value &= SPL_PQUEUE_EXTR_MASK;
+ if (!value) {
+ zend_throw_exception(spl_ce_RuntimeException, "Must specify at least one extract flag", 0);
+ return;
+ }
+ intern = Z_SPLHEAP_P(ZEND_THIS);
+ intern->flags = value;
RETURN_LONG(intern->flags);
}
/* }}} */
return NULL;
}
if (Z_ISUNDEF(user_it->value)) {
- if (spl_pqueue_extract_helper(&user_it->value, element, object->flags) == FAILURE) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- }
+ spl_pqueue_extract_helper(&user_it->value, element, object->flags);
}
return &user_it->value;
}
if (!intern->heap->count || Z_ISUNDEF_P(element)) {
RETURN_NULL();
} else {
- if (spl_pqueue_extract_helper(return_value, element, intern->flags) == FAILURE) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- RETURN_NULL();
- }
+ spl_pqueue_extract_helper(return_value, element, intern->flags);
}
}
/* }}} */