php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43020 Warning message is missing with shuffle() more than one argument
Submitted: 2007-10-18 13:41 UTC Modified: 2007-10-18 14:39 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Compile Warning
PHP Version: 5.2CVS-2007-10-18 (snap) OS: linux, windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-10-18 13:41 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
When shuffle() function is called with two arguments (ie. one argument more than expected), it performs the operation of shuffling and donot throws warning message stating for more than expected number of arguments , as we see with other functions like end() etc.

Also when shuffle() is called with zero argument(ie. one less than minimum number of argument required) the warning message is not proper and do not say anything about the insufficient number of arguments.

The following can be added in the beginning of the function definition for PHP5 to check for the above scenarios:

if (ZEND_NUM_ARGS() != 1) {
    WRONG_PARAM_COUNT;
}


Reproduce code:
---------------
<?php
$arr = array(1,2,3,4,5);
var_dump( shuffle() );
var_dump( shuffle($arr, 2) );
?>


Expected result:
----------------
Warning: Wrong parameter count for shuffle() in %s on line %d
NULL

Warning: Wrong parameter count for shuffle() in %s on line %d
NULL


Actual result:
--------------
Warning: shuffle(): could not obtain parameters for parsing in %s on line %d
bool(false)
bool(true)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-18 14:39 UTC] scottmac@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC