Psytanium Posted September 1, 2020 Share Posted September 1, 2020 Hello, Suddenly, without installing any addon or modifying anything, the website is showing "Notice: Undefined variable" in many front and back end pages, I think it's because the server did upgrade. What could be the solution ? For e.g. Notice: Undefined variable: data1 in /home/domain/public_html/includes/modules/boxes/cm_nivo_slider.php on line 84Notice: Undefined variable: button_act7 in /home/domain/public_html/includes/modules/boxes/cm_user_menu.php on line 86Notice: Undefined variable: button_act6 in /home/domain/public_html/includes/modules/boxes/cm_user_menu.php on line 87 it looks like if the variable is empty, then a notice will appear. it wasn't like this before. Any idea please ? Link to comment Share on other sites More sharing options...
♥ecartz Posted September 1, 2020 Share Posted September 1, 2020 Shop version? Edit the error_reporting in includes/application_top.php in older versions. Or in the configure.php files in the latest Phoenix. Adding & ~E_NOTICE should suppress those messages. If it is already there, this may require a conversation with your host. Turn off display_errors in php.ini or however your host does it. This may require talking to your host, although some allow you to configure this yourself. It may help to refer your host to https://stackoverflow.com/a/54215956 Always back up before making changes. Link to comment Share on other sites More sharing options...
Psytanium Posted September 1, 2020 Author Share Posted September 1, 2020 1 minute ago, ecartz said: Shop version? Edit the error_reporting in includes/application_top.php in older versions. Or in the configure.php files in the latest Phoenix. Adding & ~E_NOTICE should suppress those messages. If it is already there, this may require a conversation with your host. Turn off display_errors in php.ini or however your host does it. This may require talking to your host, although some allow you to configure this yourself. It may help to refer your host to https://stackoverflow.com/a/54215956 OSC 2.3.4 How can I fix the notices ? instead of hiding it ? Link to comment Share on other sites More sharing options...
♥ecartz Posted September 1, 2020 Share Posted September 1, 2020 Note that these notices have been there all along. The update would only have revealed them. Most likely by defaulting display_errors to on. It should never be set on in production. So you should get that turned off regardless. In general, replacing $variable with (isset($variable) ? $variable : null) will get rid of the notices. However, this is essentially the same as just turning down the error reporting, as null is the default value of an undeclared variable. The notice is basically telling you that it is doing this for you. The real fix is often to code the add-ons differently. E.g. in if (false) { $variable = 'value'; } if ('value' == $variable) { If those are the only two occurrences, you could fix this by $variable = null; if (false) { $variable = 'value'; } if ('value' == $variable) { But watch out that it isn't really if (true) { $variable = 'default'; } // doing $variable = null here would overwrite the previous value if (false) { $variable = 'value'; } if ('value' == $variable) { Note that these statements do not have to be in the same file. There isn't a strictly mechanical solution. Removing the notices properly requires understanding why they are shown and changing appropriately to that particular situation. There isn't a simple rule to apply that would be better than turning down the error reporting. Sometimes the notice may be telling you that something is wrong. E.g. $typo = true; if ($tyop) { Which can be fixed by correcting the spelling in the second line. Always back up before making changes. Link to comment Share on other sites More sharing options...
ArtcoInc Posted September 1, 2020 Share Posted September 1, 2020 @Psytanium If I may suggest, log into the Admin side of your shop, and select Tools -> Server Info. Tell us what version of PHP your host is running. Malcolm Link to comment Share on other sites More sharing options...
Psytanium Posted September 1, 2020 Author Share Posted September 1, 2020 3 minutes ago, ArtcoInc said: @Psytanium If I may suggest, log into the Admin side of your shop, and select Tools -> Server Info. Tell us what version of PHP your host is running. Malcolm PHP Version 5.6.40 MySQL 5.6.47-log OSC2.3.4 Link to comment Share on other sites More sharing options...
ArtcoInc Posted September 1, 2020 Share Posted September 1, 2020 @Psytanium Thank you. I just wanted to make sure your host hadn't upgraded PHP to version 7.x. Many hosts are moving to v7.x, which will break your version of osC. Malcolm Link to comment Share on other sites More sharing options...
Psytanium Posted September 1, 2020 Author Share Posted September 1, 2020 1 minute ago, ArtcoInc said: @Psytanium Thank you. I just wanted to make sure your host hadn't upgraded PHP to version 7.x. Many hosts are moving to v7.x, which will break your version of osC. Malcolm Ah yes.. I'm worried about this upgrade. Thx anyway Link to comment Share on other sites More sharing options...
burt Posted September 1, 2020 Share Posted September 1, 2020 This is going to be an ongoing problem for the foreseeable future for anyone on osCommerce 2.3.4 (and earlier) and for anyone on very early versions of the Community Edition. As hosts start to enforce php7 (as it is more stable and more secure than php5, and by the way php8 is soon out), we will see more and more shopowners who have run their shop only thinking about "today" rather than also thinking (at least a little) about "tomorrow" and what would happen "tomorrow" if their site went down for a day/week while they scramble about trying to get help with an outdated version or moving to a different platform etc. The Community Edition has been available for over 6 years now - that's a lot of "tomorrow" time Link to comment Share on other sites More sharing options...
Psytanium Posted September 3, 2020 Author Share Posted September 3, 2020 On 9/1/2020 at 8:24 PM, burt said: This is going to be an ongoing problem for the foreseeable future for anyone on osCommerce 2.3.4 (and earlier) and for anyone on very early versions of the Community Edition. As hosts start to enforce php7 (as it is more stable and more secure than php5, and by the way php8 is soon out), we will see more and more shopowners who have run their shop only thinking about "today" rather than also thinking (at least a little) about "tomorrow" and what would happen "tomorrow" if their site went down for a day/week while they scramble about trying to get help with an outdated version or moving to a different platform etc. The Community Edition has been available for over 6 years now - that's a lot of "tomorrow" time Is there any documentation or forum topic that can help us migrate from 2.3.4 to the latest version ? Because I can't start a new website with all the hardcoded modifications and huge database. Thanks Link to comment Share on other sites More sharing options...
burt Posted September 3, 2020 Share Posted September 3, 2020 1 minute ago, Psytanium said: Is there any documentation or forum topic that can help us migrate from 2.3.4 to the latest version ? Because I can't start a new website with all the hardcoded modifications and huge database. Thanks No two sites from a decade or more ago are the same, therefore it is not possible to write a generic topic that would cover all sites. Shopowners need to get out of the habit of jumping to core code changes and instead work out ways to have *similar* functionality without having to resort to core code modifications. The old awful ways of getting better functionality (in 2.2) were alleviated a bit in the 2.3 series and have been *almost* removed in Phoenix (where it is possible to do most things without touching core). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.