Undefined global variable $_SESSION and no zc log files
zc158a; PHP 8.2.15; PHP Memory Limit: 128M; DB MySQL 10.6.16-MariaDB-0ubuntu0.22.04.1
Note: This is no longer a problem on my site and the information is posted here for the search engines to find for future reference.
I could not edit one database record, found by chance, when checking on stock returned. The order details screen showed the order number and the remainder of the page was blank. No Zen Cart error logs were displayed.
I was getting the following error in my Apache logs
Code:
PHP Warning: Undefined global variable $_SESSION in .../includes/extra_configures/enable_error_logging.php on line 84
with no zen cart error logs generated.
The problem was inadequate permissions on the logs folder. This was resolved when the folder permission was set to 774.
When the log files could be generated I had Zen Cart error logs complaining about duplicate defined names. These were due a legacy language file existing beside a 158 format lang file.
The duplicate defines errors does not occur on my Windows development machine or on my linux test machine.
When these redundant files were removed and no further zc log files were generated. The database record displayed correctly.
Re: Undefined global variable $_SESSION and no zc log files
I'm possibly wrong, but the duplicate definition logging issue could be or could have been averted through the logging configuration settings.
The missing session issue likely occurred because the problem occurred before either the session code was loaded or the language code but after the error logging was initiated. This was resolved through one of 250+ PRs on the v158 branch after version 1.5.8a was released. Specifically: Allow intended error logging before `$_SESSION` set by mc12345678 · Pull Request #5868 · zencart/zencart (github.com)
Re: Undefined global variable $_SESSION and no zc log files
Quote:
Originally Posted by
mc12345678
Since the issue was thrown by a file in the extra_configures sub-directory, the logging configuration has no play in the issue since files in that sub-directory are loaded prior to initiating database access (i.e. where those configuration settings are stored).