php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23268 str_replace total system overload
Submitted: 2003-04-18 06:31 UTC Modified: 2003-04-23 00:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: nick at netdupe dot com Assigned:
Status: No Feedback Package: Performance problem
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-04-18 06:31 UTC] nick at netdupe dot com
If you accidently put something like the following in 
str_replace the server goes nuts and does not return 
any information.

<?
$code = "hello";
$string = "Hello, Bob how are you";
$text = str_replace("$code", "hey", $string);
?>

This only occurs when you put $code in quotation marks. 
Shouldnt it come up? I did this the server load went 
from 0.05 to 23.4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-18 06:33 UTC] nick at netdupe dot com
got a little mistake in there, "shoudnt it come up?" 
should be "shoudnt it come up with an error?"
 [2003-04-18 09:40 UTC] magnus@php.net
I could not reproduce it with exactly that code. 
Tried both 4.3.0 and current PHP_4_3 branch. 
 [2003-04-18 17:07 UTC] nick at netdupe dot com
ok this is the code i used it with:
<?
$file = file("smillies.db");
      foreach($file as $value){
           list($rand,$code,$image) = explode("|<|", 
$value);
           $code = stripslashes($code);
           $fusnewsm = str_replace("$code","<img 
src=\"http://images.devdino.com/smillies/$image\" 
border=\"0\">",$fusnewsm );
      }
?>
You will need smilies.db you can get it from
www.devdino.com/smillies.db.
 [2003-04-18 17:21 UTC] pollita@php.net
Significant portions of the str_replace function are rewritten in the development branch.  Can you try downloading a snapshot of PHP-5.0-dev and seeing if the problem persists?  I'd also like to ask you to try the latest snapshot of the stable branch. PHP-4.3-stable

http://snaps.php.net

And incidently your first example shouldn't come up with any error, it should simply fail to replace anything (str_replace is case-sensitive)
 [2003-04-23 00:21 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Oct 05 06:05:53 2022 UTC