Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All

Bug #18350 _qpReplaceCallback has to be static
Submitted: 2011-03-09 21:03 UTC
From: dbdb Assigned: alec
Status: Closed Package: Mail_Mime2
PHP Version: 5.2.12 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2011-03-09 21:03 UTC] dbdb (Dennis Björklund)
Description: ------------ In PHP 5.2.17 it fail to encode strings properly in mimePart.php line 1137: $char = preg_replace_callback( $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char ); Making _qpReplaceCallback a static member function solves the issue for me.

Comments

 [2011-03-10 01:37 UTC] alec (Aleksander Machniak)
It works for me with PHP 5.3, so what is the error message? We can't use 'static' keyword because we must be PHP4 compatible.
 [2011-03-10 18:36 UTC] dbdb (Dennis Björklund)
When called as a static function but it isn't then php (here) overwrite the $regexp value with something else and in the next iteration I get an error message that the regexp is invalid. I assume some stack is involved and the $this pointer isn't where it should be. This is one of the messages I get. preg_replace_callback() [function.preg-replace-callback]: Delimiter must not be alphanumeric or backslash in function preg_replace_callback in /usr/local/lib/php/Mail/mimePart.php on line 1138 If I replace the code $char = preg_replace_callback( $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char ); with $x = $regexp; $char = preg_replace_callback( $x, array('Mail_mimePart', '_qpReplaceCallback'), $char ); it also work for me, then it is $x that get overwritten by the call. Don't know why it only happens here, but it does.
 [2011-03-10 18:51 UTC] alec (Aleksander Machniak)
Strange. Does any of package's test scripts fail in your environment? If not, could you provide a test script?
 [2011-09-15 18:13 UTC] belug (Alexandre Lessard)
Here I have the same bug and the solution given by Dennis Björklund works for me too. My version of PHP is 5.2.6-1+lenny9 With some tests i've found that in the subject if i don't have accents it works perfectly. I have to do french communications so I need accent in the subject and with the last name of M. Björklund, I think that he could have some accents too in his subject. I,ve tryed with UTF-8 or latin encoding of the accents and it does the same bug. Thanks Dennis Björklund for the temporary patch. I just hope that something more permanent could be added to the projet to prevent any broken code when updating. Alexandre Lessard.
 [2011-10-14 19:07 UTC] sunmar (Marijn van Zon)
Hi, Got the same issue and the change proposed by dbdb seemed to fix it. I do seem to notice it triggered when there are 'special' characters present like the 'o' in "Björklund" that delug provided as example. Any outlook on when this will be fixed in a stable release? My error messages are: [13-Oct-2011 15:01:49] PHP Warning: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Delimiter must not be alphanumeric or backslash in /usr/share/pear/Mail/mimePart.php on line 1138 [13-Oct-2011 15:01:49] PHP Warning: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: No ending delimiter '_' found in /usr/share/pear/Mail/mimePart.php on line 1138 [13-Oct-2011 15:01:49] PHP Warning: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: No ending delimiter ')' found in /usr/share/pear/Mail/mimePart.php on line 1138 Regards, Marijn.
 [2011-10-14 19:10 UTC] alec (Aleksander Machniak)
Would be faster if I could reproduce it. Provide test script, please.
 [2011-10-27 15:55 UTC] dbdb (Dennis Björklund)
I've tried a to create a small test case that show the problem but (of course) it work when I do. It's only in a very large project at work I've seen it fail and adding the static keyword and not altering anything else make it work. It must be something else we we do as well that trigger this bug. The project at work has lots of error handlers, exception handling and who knows what else that might affect this. To me it look like a memory or stack corruption and thus a bug in php itself.
 [2012-03-12 18:07 UTC] alec (Aleksander Machniak)
-Status: Open +Status: Closed -Package: Mail_Mime +Package: Mail_Mime2 -Assigned To: +Assigned To: alec
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. qpReplaceCallback() method has been marked static in git for Mail_Mime2 package. We cannot do this for Mail_Mime, because it must be PHP4 compatible.