Re: possible bug zend_hash_sort(...)

From: Date: Tue, 26 Jun 2001 13:47:00 +0000
Subject: Re: possible bug zend_hash_sort(...)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-58043@lists.php.net to get a copy of this message
I'd say that this is a bug, and needs to be fixed. Zeev At 15:40 26/6/2001, Andre Langhorst wrote:
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 *
-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.dev (#58043) next »