#42142 [NEW]: substr_replace() returns FALSE

From: Date: Sun, 29 Jul 2007 22:54:27 +0000
Subject: #42142 [NEW]: substr_replace() returns FALSE
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115540@lists.php.net to get a copy of this message
From: fznohluwlempsh at mailinator dot com Operating system: all of them PHP version: 5.2.3 PHP Bug Type: Unknown/Other Function Bug description: substr_replace() returns FALSE Description: ------------ After upgrading from 5.2.1 to 5.2.3, my app broke. Why? Because I had the audacity to use substr_replace() in a perfectly reasonable way. This isn't rocket science. If $length is longer than the length of $string, substr_replace() should return the same as if $length was not given. It should not return FALSE. Hell, it doesn't even return FALSE if you specify the string 'blow me' as $length. Fuck the what? And don't even think about giving me the standard bullshit "please double-check the documentation" non-answer that bug report #41395 got on this same issue. I triple-checked the documentation, and nowhere did it say, "Oh, and now it sometimes returns FALSE for no fucking reason. Sit and spin -- we'll break compatibility in sub-point releases whenever we goddamn want." Reproduce code: --------------- <?php var_dump(substr_replace('12345', 'abc', 3)); var_dump(substr_replace('12345', 'abc', 3, 3)); var_dump(substr_replace('12345', 'abc', 3, 4)); var_dump(substr_replace('12345', 'abc', 3, 5)); var_dump(substr_replace('12345', 'abc', 3, 6)); Expected result: ---------------- string(6) "123abc" string(6) "123abc" string(6) "123abc" string(6) "123abc" string(6) "123abc" Actual result: -------------- string(6) "123abc" string(6) "123abc" string(6) "123abc" string(6) "123abc" bool(false) <-- This shit is broke! -- Edit bug report at http://bugs.php.net/?id=42142&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42142&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42142&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42142&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42142&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42142&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42142&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42142&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42142&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42142&r=support Expected behavior: http://bugs.php.net/fix.php?id=42142&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42142&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42142&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42142&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42142&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42142&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42142&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42142&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42142&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42142&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42142&r=mysqlcfg

« previous php.bugs (#115540) next »