Re: php 5.4 fatal error, query factory
I've seen something similar to this during plugin development (i.e. self-induced) and was able to ultimately work-around the issue by clearing the session cookies for the site. Please note that I said "work-around", not solution!
You can see, without any special debuggers, what's going on in the store by installing the Zen Cart Notifier Trace (http://www.zen-cart.com/downloads.php?do=file&id=1114) and then try logging in. Be sure to go back to your admin once you've captured the set of notifiers and turn the Notifier Trace off (Configuration->Logging) because the file can grow very large very quickly ... especially with the condition you're describing.
The plugin creates a file in your /cache folder named notifier_trace.log and contains a list of all the page-level processing that's transpired.
Re: php 5.4 fatal error, query factory
I had the same problem with one of the errors mentioned at the top of this thread:
[18-Aug-2013 06:25:53 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 3715690265 bytes) in /home/xxxxxxx/public_html/includes/functions/html_output.php on line 62
BRAND NEW install of Zen Cart 1.5.1 - no mods - clean database.
What worked for me to get rid of the problem with getting a blank page when trying to log in was to go to Configuration>Sessions>Force Cookie Use and change it to True
Once I did that, no more problems with logging in
Hope this helps someone!
Re: php 5.4 fatal error, query factory
Found and Fixed!
The problem is that when php shuts down global variables might already have been deleted when the default session write and close happens. There doesn't seem to be any synchronization between the two processes. Here are the php bug tickets regarding this:
This has all the pertinant info:
https://bugs.php.net/bug.php?id=54157
http://www.mediawiki.org/wiki/Specia...i/83140#c14601
Quote:
On request shutdown, PHP does things in the following order:
register_shutdown_function() functions
zend_call_destructors()
zend_deactivate_modules()
zend_call_destructors() goes through the $GLOBALS symbol table and identifies every global variable that holds an object which has a reference count of 1. It removes these globals. It doesn't decrement any reference counts. Any globals which are not objects, or have a reference count greater than 1, are left in the symbol table.
I believe the "fixes" that have worked for people have simply moved the symbol table around enough that the global $db is still active when session_write is called in zencart.
The fix is to set a shutdown function that does a session write close itself:
Code:
register_shutdown_function('zc_shutdown');
function zc_shutdown() {
// other shutdown code as needed
// write session now
session_write_close();
}
Then in includes/functions/sessions.php, in _sess_write, change to:
Code:
if (!is_object($db)) {
//error_log('session write with no global db variable! sessions.php .60');
// https://bugs.php.net/bug.php?id=54157
// session could be closed with no global variables
// if so, just exit, nothing we can do
// workaround is to register shutdown function that saves session
// and this last call is no-op
return;
//PHP 5.2.0 bug workaround ...
// if (!class_exists('queryFactory')) require('includes/classes/db/' .DB_TYPE . '/query_factory.php');
// $db = new queryFactory();
// $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);
}
If we come upon a session write where we don't have global variables, it's probably because they've been destroyed. This is OK because we have already done a session write in our shutdown function, so we can ignore this session write. Of course, do not set any session variables after the shutdown function is called.
This has worked in two cases where I had this strange "session write with no global $db" value in php 5.3 and 5.4.
Re: php 5.4 fatal error, query factory
Re: php 5.4 fatal error, query factory
I downloaded the github code and saved that version of /includes/functions/sessions.php to my otherwise unmodified ZC v1.5.1 test site running PHP 5.4.21. I've got the replication of this down to a time-consuming couple of steps:
- Make sure that you are logged out of the store
- Click Login, then the "Password Forgotten" link. Enter your email address and request a new password.
- Wait for the 24-minute (I usually waited an hour to be sure) session timeout to expire.
- From the login page (where you were redirected after confirming the forgotten password), enter your email address and the password you received in the email.
- You're redirected to the time_out page because the session expired. Enter your email address and new password and press Enter.
- Experience the whitescreen experience. The log that's created is "memory exhausted" by html_output.php.
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
I downloaded the github code and saved that version of /includes/functions/sessions.php to my otherwise unmodified ZC v1.5.1 test site running PHP 5.4.21. I've got the replication of this down to a time-consuming couple of steps:
- Make sure that you are logged out of the store
- Click Login, then the "Password Forgotten" link. Enter your email address and request a new password.
- Wait for the 24-minute (I usually waited an hour to be sure) session timeout to expire.
- From the login page (where you were redirected after confirming the forgotten password), enter your email address and the password you received in the email.
- You're redirected to the time_out page because the session expired. Enter your email address and new password and press Enter.
- Experience the whitescreen experience. The log that's created is "memory exhausted" by html_output.php.
So, in another thread, one of the ZC knowledgeable suggested the following thread for a memory issue. My apologies if it happens to lead back here or to the same suggested fixes as in here. Trying to provide some input where I've seen a similarity.
http://www.zen-cart.com/showthread.p...ytes-exhausted
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
mc12345678
So, in another thread, one of the ZC knowledgeable suggested the following thread for a memory issue. My apologies if it happens to lead back here or to the same suggested fixes as in here. Trying to provide some input where I've seen a similarity.
http://www.zen-cart.com/showthread.p...ytes-exhausted
Right, the reason for my post is that the code update to /includes/functions/sessions.php referenced by both this and the post you indicated might correct "part" of the problem, but the 'memory exhausted' issue is still there even with the code update.
The log I received was
Code:
[22-Nov-2013 13:14:55 America/New_York] PHP Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 746619897 bytes) in xxx/includes/functions/html_output.php on line 62
... the referenced line being the relatively innocuous
Code:
if (defined('SID') && zen_not_null(SID)) {
Re: php 5.4 fatal error, query factory
Can you install Xdebug (http://www.xdebug.org/) on your server? It prints a call stack whenever there is a fatal error so you can see the function path to the crash. If the crash is not in session_write then you might have a different crash issue. I'll see if I can test this too soon.
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
avibodha
Can you install Xdebug (
http://www.xdebug.org/) on your server? It prints a call stack whenever there is a fatal error so you can see the function path to the crash. If the crash is not in session_write then you might have a different crash issue. I'll see if I can test this too soon.
It's going to be "difficult" to get this installed on my host. I did install it on my localhost (xampp) environment (PHP 5.4.8) on my Windows 7 machine. Going through the same sequence in that environment (my test installation for the failing Linux-hosted store) results in no error, so it's either a PHP version or Linux vs. Windows session-handling issue. In both cases, I used the most recent version of FireFox as the browser.
If it will help, I can PM you a copy of the phpinfo() from the failing hosted environment ...
Re: php 5.4 fatal error, query factory
I also started experiencing same problem after I migrated to Godaddy unlimited shared hosting from another Godaddy hosting. I copied fixed version of "session.php" from github. But problem persist. FYI: My zen cart version is 1.51
Here is error message from Godaddy when I try to login. It stuck on below blank page.
/index.php?main_page=login&action=process
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
"
Here is Zen cart log.
[26-Nov-2013 01:24:40 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 693694233 bytes) in /home/xxxxx/public_html/includes/functions/html_output.php on line 62
"
Is there any other fix?
Quote:
Originally Posted by
DrByte