php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69751 Change Error message of sprintf/printf for missing/typo position specifier
Submitted: 2015-06-03 11:59 UTC Modified: 2021-01-06 16:20 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Hoffmann dot P at gmx dot net Assigned:
Status: Closed Package: Strings related
PHP Version: 5.5.25 OS: Linux 3.13.0-53-generic
Private report: No CVE-ID: None
 [2015-06-03 11:59 UTC] Hoffmann dot P at gmx dot net
Description:
------------
I suggest a more comprehensible error message (see suggestion in "Expected result"). The current error message was missunderstood by me as "The number of arguments of the function is zero (and must be greater than zero)". Instead it was the number of the position specifier argument that was missing (type, "$" and "1" where reversed).

Test script:
---------------
sprintf("%$1s, %2$s %1$s", "Sir", "Yes");

Expected result:
----------------
Missing position specifier number in /home/ber/Code/Kompetenztest/org/ValiditätEingabe/class_test.php on line $line

Actual result:
--------------
Argument number must be greater than zero in /home/ber/Code/Kompetenztest/org/ValiditätEingabe/class_test.php on line $line

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-04 12:04 UTC] cmb@php.net
-Package: SPL related +Package: Strings related
 [2015-06-04 12:04 UTC] cmb@php.net
See <http://3v4l.org/CPIng> for a corrected test script.
 [2021-01-06 16:14 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-01-06 16:14 UTC] cmb@php.net
Yes, that error message is not right.  You also get the same error
message if the argnum is greater than INT_MAX[1].

[1] <https://3v4l.org/gs2fF>
 [2021-01-06 16:20 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Bug
 [2021-09-29 10:22 UTC] git@php.net
Automatic comment on behalf of Flashwade1990 (author) and nikic (committer)
Revision: https://github.com/php/php-src/commit/41df5c0675daf1bb1d86e5e53e75490e3e0614bf
Log: Fix bug #69751
 [2021-09-29 10:22 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 09 09:03:33 2021 UTC