dbo Posted April 1, 2008 Share Posted April 1, 2008 So... I thought there was a bug in my code and I went debugging. Despite telling my system not to cache files, it was doing so anyways. I tracked down the issue to this code: //IF WE DIDN'T POPULATE THE CONTENTS FROM THE CACHE, AND THE FILE //IS CACHEABLE WE WANT TO WRITE IT TO CACHE $test = (!$blnFromCache && $this->blnIsCacheable); debug_zval_dump($test); if( $test ) { $strFilename = $this->getCacheId(); //file_put_contents(CACHE_DIR . $strFilename . ".php", $this->strContents); } This outputs false for the debug statement... meaning that it should not enter the if statement. Since I've got the file_put_contents thing commented out, the contents are not written to file. So I uncomment it and it writes it to cache. How can it write anything to cache if $test is false? I don't get it. Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/ Share on other sites More sharing options...
keeB Posted April 1, 2008 Share Posted April 1, 2008 I really don't understand how this is a bug.. ? Can you elaborate? Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506211 Share on other sites More sharing options...
dbo Posted April 1, 2008 Author Share Posted April 1, 2008 Bug confirmed. Wrapping file_put_contents in my own function call, only gets executed when $test evaluates as true... as it's supposed to. Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506212 Share on other sites More sharing options...
dbo Posted April 1, 2008 Author Share Posted April 1, 2008 A line of code executing inside of an if statement, even when the if statement evaluates to false is not odd to you? Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506213 Share on other sites More sharing options...
dbo Posted April 1, 2008 Author Share Posted April 1, 2008 Hrmmm. I lied. My function is still getting executed when it evaluates to false too. Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506219 Share on other sites More sharing options...
dbo Posted April 1, 2008 Author Share Posted April 1, 2008 I don't get stumped often... but I'm at a loss with this one. Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506221 Share on other sites More sharing options...
keeB Posted April 1, 2008 Share Posted April 1, 2008 I'm not convinced it's false. Link to comment https://forums.phpfreaks.com/topic/98932-this-is-bizarre-i-think-i-found-a-bug-in-php/#findComment-506239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.