ID:               47560
 Updated by:       fel...@php.net
 Reported By:      RQuadling at GMail dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Strings related
 Operating System: Windows XP SP3
 PHP Version:      5.3CVS-2009-03-04 (snap)
-Assigned To:      
+Assigned To:      Kalle
 New Comment:

Hi Kalle,
This issue looks like documentation problem. I guess that your commit
to #47546 must be reverted.


Previous Comments:
------------------------------------------------------------------------

[2009-03-04 12:37:37] RQuadling at GMail dot com

Description:
------------
With regard to #47546, the behaviour of no $limit supplied and $limit 
supplied as the default now match, but the output is wrong.

I've run the following code for V5.2.8, V5.2.10-dev and V5.3.0beta2-
dev (the devs are the latest win32 snapshots).

Here is a summary ...

V5.2.8
No limit - 4 entries
Limit of -4 - No entries
Limit of -3 - 1 entry
Limit of -2 - 2 entries
Limit of -1 - 4 entries *** Should be 3 entries
Limit of 0 - 1 entry
Limit of 1 - 1 entry
Limit of 2 - 2 entries
Limit of 3 - 3 entries
Limit of 4 - 4 entries *** Matches No Limit

5.2.10-dev and 5.3.0beta2-dev
No limit - 4 entries
Limit of -4 - No entries
Limit of -3 - 1 entry
Limit of -2 - 2 entries
Limit of -1 - 4 entries *** Should be 3 entries but does match No 
Limit
Limit of 0 - 1 entry
Limit of 1 - 1 entry
Limit of 2 - 2 entries
Limit of 3 - 3 entries
Limit of 4 - 4 entries *** Matches No Limit


It would seem that the idea of limit has a static value default is 
inappropriate. If anything the default for limit is the number of 
elements in no limiting takes place.

Also a limit of -1 should be returning 3 elements and not 4.

Richard.

Reproduce code:
---------------
<?php
$s_Imploded = 'one.two.three.four';
$s_Exploded = serialize(explode('.', $s_Imploded));

echo PHP_VERSION, PHP_EOL;
echo 'No limit supplied.', PHP_EOL, var_export(explode('.',
$s_Imploded), True), PHP_EOL;

for ($i_Limit = -4 ; $i_Limit <= 4 ; ++$i_Limit)
        {
        echo "Testing limit of $i_Limit", PHP_EOL, var_export(explode('.',
$s_Imploded, $i_Limit), True), PHP_EOL;
        if (serialize(explode('.', $s_Imploded, $i_Limit)) === $s_Exploded)
                {
                echo "A limit of $i_Limit matches the output when no limit has 
been
supplied.", PHP_EOL;
                }
        echo PHP_EOL;
        }





------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47560&edit=1

Reply via email to