[solved] Magic __destruct - Win vs. Mac |
[eluser]PhilTem[/eluser]
Hey everyone, long time nothing but replies and answers from me, but now I'm back with a problem/question myself. I just changed my development machine from a Win7 to a MacBook Pro with OS X Lion. And I had thought, everything works well on a UNIX-like system after copy-pasting my files from the Win-machine. But obviously it didn't. Here's what happens: There's a library with the magic __destruct function which basically does nothing else than just write some data to the session. Code looks like this Code: // Check if we got the CI object. If we don't have any, we would trigger errors with With my Windows machine there are no errors coming up when accessing any page. However, Mac prompts the following Quote:Warning: include(icf/errors/error_php.php) [function.include]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/icf/codeigniter/core/Exceptions.php on line 182 I did a debug_backtrace() on line 182 of Exceptions.php and I see a line stating Quote:[function] => show_php_error which actually says: Output sent, cannot change the session anymore. So now I got two questions: 1) Why didn't I receive these errors on my Windows machine? 2) How can I solve my problem? The idea, why I added the __destruct method, was to wait for all messages to be defined and then just write the session data instead of writing it over and over again whenever a new message is set (the library shall be used for flash-messages). Maybe somebody, who is not overwhelmed by my long post, can shed some light on this issue - even though I thought I knew how to write PHP and knew all the tricks of PHP. Thanks!
[eluser]CroNiX[/eluser]
Not sure about that problem, sorry, but I do know that the mac's version of PHP crypt() does not make use of md5(), which is technically a good thing, except when you are working with legacy code and don't have a choice and need md5 w/crypt(). Took a long time troubleshooting that one when I was using an auth system that used crypt w/md5 to hash passwords. The passwords weren't transferable due to this limitation. Actually, your first problem is probably because it can't find that file, so it's outputting the error which messes with the headers being sent already. Make sure /Applications/XAMPP/xamppfiles/htdocs/icf/codeigniter/core/Exceptions.php exists, has proper file and user/group permissions.
[eluser]CroNiX[/eluser]
Also, check what your document root is set to. It seems it can't find this file due to its relative path. Failed opening ‘icf/errors/error_php.php’ for inclusion
[eluser]PhilTem[/eluser]
Thanks for your replies, CroNiX, unfortunately they didn't help at all. I checked all file-permissions, checked all defined constants in index.php. Everything is as it should be. I also downloaded a clean CI 2.1.1 and let it run with no problems and when I run my current project with the Message-library in autoload.php, it doesn't work. However, removing it from autoload.php or commenting the __destruct()-method will result in no errors. For me it seems like a strange behavior of the __destruct()-method in combination with the session's library. The error mentioned above which states it cannot include the file 'error_php.php' is probably because the CI super-object is already (partially) destroyed and therefore the constants and paths don't exist anymore resulting in the error. I guess, there seems to be some spot I really don't get for fixing the problem. Would there be a solution to obviate the __destruct()-method completely, because I can't see any at the moment.
[eluser]InsiteFX[/eluser]
Hi PhiTem, You can also try this: register_shutdown_function Code: One can however register the destructor or another method as a shutdown function: I would place this in your MY_Controller
[eluser]PhilTem[/eluser]
@InsiteFX: Tried that one, too, yet it won't change the result in any way. And right now I'm really at my wit's end...
[eluser]CodeIgniteMe[/eluser]
I think it is the PHP.ini equivalent in your OSX that is causing the problem. Note that the error is just a warning. Probably your Win7 machine has PHP warning messages disabled. Not sure though, I never had used a Mac, but I encountered this type of error before when migrating my PHP projects from Windows to Ubuntu. Hope this helps
[eluser]PhilTem[/eluser]
I'm not 100% convinced that it may be a problem with my PHP.ini since this should actually be obviated with the ENVIRONMENT switch setting error_reporting to E_ALL for 'development'. But I'll do some further investigation on the weekend and maybe I will find a solution...
[eluser]InsiteFX[/eluser]
PhilTem, Read this: PHP generates a warning inside a class destructor when you try to read a file
[eluser]PhilTem[/eluser]
Thanks @InsiteFX, you're my man Though it tells me at least: I'm not too stupid for developing things in PHP. However, it's said to see the bug report still being open and not solved. Anyway, I also think it may be problem due to different PHP versions: ApacheFriends delivers PHP 5.3.1 for Mac OS X based XAMPP and PHP 5.3.8 for Windows based XAMPP. This might resolve in different error handling for that particular error. Now I just have to find a solution or a workaround which satisfies my (personal) requirements^^ |
Welcome Guest, Not a member yet? Register Sign In |