Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #12712 Unconditional use of file_put_contents()
Submitted: 2007-12-18 00:20 UTC
From: yunosh Assigned: dufuz
Status: Closed Package: PEAR (version 1.7.0RC1)
PHP Version: 4.4.7 OS:
Roadmaps: 1.7.0    
Subscription  


 [2007-12-18 00:20 UTC] yunosh (Jan Schneider)
Description: ------------ If using the run-tests -x flag to enable code coverage reports, a file_put_contents() call is added unconditionally at the end of all generated .php files. file_put_contents() is only available with PHP 5. Since Xdebug's code coverage works perfectly with PHP 4, I suggest to replace it with traditional fopen()/fwrite() calls.

Comments

 [2007-12-29 01:50 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This bug has been fixed in CVS. 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. I just took the easy way and added a file_put_contents hack at the bottom of the file so that if you are running PHP 4 it should work.
 [2007-12-29 02:54 UTC] cellog (Greg Beaver)
as noted, not quite fixed yet, the fix is in RunTests.php but this is a separate process from the tests
 [2007-12-29 04:03 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This bug has been fixed in CVS. 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. Look at cvs, hopefully it's fixed now. Jan can you test this diff for me: http://cvs.php.net/viewvc.cgi/pear-core/PEAR/RunTest.php?r1=1.59&r2=1.60&view=patch Just switch PHP_VERSION and '5', I forgot to change it back before the commit
 [2007-12-29 10:04 UTC] yunosh (Jan Schneider)
There were some missing parentheses. I also used function_exists() instead of version_compare() which is semantically more correct and works with patched PHP installations, disabled functions, etc.
 [2007-12-30 00:06 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Sorry about that Jan, I was having a really bad night as you saw by my multiple failed commits, I should have stopped after the this failure :-) I'll produce a new patch tonight, can you perhaps swing by at IRC ?
 [2007-12-30 00:38 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Can you try this patch ? http://cvs.php.net/viewvc.cgi/pear-core/PEAR/RunTest.php?r1=1.61&r2=1.62&view=patch I'm not sure what was missing that you are talking about but I did go with function exists and changed from double quotes back to single since Windows seems to behave properly with that, with double I had to escape the backslashes. This worked in the tests I did but I'm not on PHP 4 nor did I have xdebug around (I commented that part out since we weren't anyway fixing up xdebug issues) Let me know.
 [2007-12-30 09:45 UTC] yunosh (Jan Schneider)
Looks like yesterday wasn't any better for you. ;-) I already attached a patch with my last comment.
 [2007-12-30 19:23 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Can you attach a real patch ? something doing $text.= to $text .= isn't really helpful since the standard doesn't prohibit this :)
 [2007-12-30 19:27 UTC] dufuz (Helgi Þormar Þorbjörnsson)
I'm trying to look at your patch and ignoring the space adding, why didn't you make it from the latest CVS head ? Because to me it looks a lot like http://cvs.php.net/viewvc.cgi/pear-core/PEAR/RunTest.php?r1=1.59&r2=1.62&view=patch (included couple of revisions just so it looks more complete) just that I did !function_exists and you did function_exists Am I missing some important change in your code I didn't commit ? :-o
 [2007-12-30 23:37 UTC] yunosh (Jan Schneider)
It *is* against the latest CVS. At least at the time I uploaded the patch. The second important change beside function_exists() is to encapsulate the $fh = fopen() in parentheses so that you can correctly compare that expression with false. Regarding the concatenation operator: it's common sense to have a single space next to operators, even if it's not explicitly mentioned in the coding standards.
 [2007-12-31 16:53 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This bug has been fixed in CVS. 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. In my patch if you had looked I did move the fopen call outside of the if sentence so I didn't have to encapsulate it :) Regarding the common sense stuff, originally the code looked like this: $foo = ''; $foo.= 'morestuff'; it felt more like a flow then: $foo = ''; $foo .= 'morestuff'; I haven't changed it since I wanted to fix the bug first, even if you do not want to test my patch I take it as it works since they are so similar and it worked quite fine for me.