possible bug zend_hash_sort(...)
| From: | Andre Langhorst | Date: | Tue, 26 Jun 2001 12:40:05 +0000 |
| Subject: | possible bug zend_hash_sort(...) | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-58040@lists.php.net to get a copy of this message | ||
Hi,
apparently php-users are fooled (bug 9633, private email to me) by zends sorting on one-element arrays. In fact we do nothing there.
if (ht->nNumOfElements <= 1) { /* Doesn't require sorting */ return SUCCESS;
}but zend_hash_sort is called with renumber=1 for sort() and the like. thus any array with size>1 will be renumbered except the one element array, that one is returned unchanged. shoudn't have renumbering an effect on one-element arrays even if there is nothing to sort? POV 1) One element, nothing to sort. Simply return it. Problem: inconsistent behaviour POV 2) Renumber arrays with size>1, renumber all. Problem: backwards compatibilty. well, I am unsure. To not have the BC problem we should at least document this, because experience shows that people do expect that sort() acts similar on all arrays and renumbers even one-element arrays. ok. why would you sort a one-element array? I wouldn't, but people apparently do and I can understand this kind of inconsistency assuming. andré
· andre@php.net m: +49 173 9558736 ·* PHP Quality Assurance http://qa.php.net *