anabis Posted January 10, 2018 Share Posted January 10, 2018 Hello all, I hope someone will be able to help. My client played around with some modules configurations this afternoon, I wasn't beside him so I am not exactly sure what he did, but I'm sure nothing foolish, at least he didn't edit code or anything. But now I have this error in my nginx error log PHP message: PHP Fatal error: Cannot declare class language, because the name is already in use in /var/www/shop/includes/classes/language.php on line 16" while reading response header from upstream, client: 92.256.256.94, server: *.myshop.com, request: "GET /shop/index.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "myshop.com", referrer: "https://myshop.com/shop/index.php?cPath=25" This happens on all pages except on '/shopping_cart.php' and it happens only when the user has at least one item in its cart. So when it happens it is possible to go to this page and remove the cart content. I have tried hunting another declaration of a 'language' variable, found only things like this # grep language includes/functions/cache.php global $cPath, $language; (in other files too) and temporarily removing/commenting these either break more things or doesn't solve the problem. If someone can bring any help on this that would be awesome ! Thank you! Link to comment Share on other sites More sharing options...
♥kymation Posted January 10, 2018 Share Posted January 10, 2018 This error is usually the result of uploading the code for a module to the languages directory. That is, something that should go in includes/modules/shipping was loaded into includes/languages/english/modules/shipping. Or something similar. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
anabis Posted January 10, 2018 Author Share Posted January 10, 2018 Thank for your quick answer, What can I do to find which module file is in the wrong directory ? The error message isn't very helpful. By the way, I'm not sure if the error happens because a language class has already been declared in /includes/classes/language.php, or if it happens when it tries declaring this class in this file. All files under the includes/languages/english/modules/ directory contains only define directive so I guess they're correct. No files under includes/modules/ are such "define only" files.. Link to comment Share on other sites More sharing options...
♥kymation Posted January 10, 2018 Share Posted January 10, 2018 The /includes/classes/language.php file is included into other files that need to use the language class. The error usually means that the file has been included more than once, which usually means a file in the wrong place. There is another possibility: this error message could itself be incorrect. I remember this happening with older versions of PHP and certain security settings (likely in Centos). The fix is to upgrade to a newer version of PHP, as the code that is causing the error is perfectly valid, and the actual problem is a bug in PHP. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
ArtcoInc Posted January 10, 2018 Share Posted January 10, 2018 @anabis At the risk of asking the obvious, do you (or your client) have a backup of the site before the changes were made? Malcolm Link to comment Share on other sites More sharing options...
anabis Posted January 10, 2018 Author Share Posted January 10, 2018 1 hour ago, kymation said: The /includes/classes/language.php file is included into other files that need to use the language class. The error usually means that the file has been included more than once, which usually means a file in the wrong place In which case replace the include function with include_once would fix the problem ? Still, any idea as to where to find that faulty file ? 1 hour ago, kymation said: There is another possibility: this error message could itself be incorrect. I remember this happening with older versions of PHP and certain security settings (likely in Centos). The fix is to upgrade to a newer version of PHP, as the code that is causing the error is perfectly valid, and the actual problem is a bug in PHP. I am running version 7.0.27, I think I can rule out that possibility. 1 hour ago, ArtcoInc said: At the risk of asking the obvious, do you (or your client) have a backup of the site before the changes were made? Malcolm Yes I do, fairly recent, I'll resort to this if there is no other way. Thanks Link to comment Share on other sites More sharing options...
♥kymation Posted January 10, 2018 Share Posted January 10, 2018 You can search for language.php in the files and change the include to include_once in each case. If that makes the error message go away, you had a file in the wrong place, and you still need to find that and fix it. It's possible that PHP 7.0.27 has a regression bug, or that the security changes that Centos makes to the default system will cause this problem for any version of PHP. The bug has never been traced to that level. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
anabis Posted January 10, 2018 Author Share Posted January 10, 2018 9 minutes ago, kymation said: You can search for language.php in the files and change the include to include_once in each case. That worked ! language.php was included in these files admin/includes/application_top.php includes/application_top.php includes/modules/social_bookmarks/sb_google_plus_one.php includes/modules/social_bookmarks/sb_google_plus_share.php includes/modules/header_tags/ht_google_adwords_conversion.php includes/modules/boxes/bm_languages.php I changed include() to include_once() in each of them, the bug disappeared and then I reverted back to include(), checking if the bug re-appeared between each of them. That led me to the conclusion that the wrong file was includes/modules/boxes/bm_languages.php. But this file is untouched from the oscommerce 2.3.4.1original zip, so I wonder what has happened, and if I went through the whole problem here. What do you think ? Link to comment Share on other sites More sharing options...
♥kymation Posted January 10, 2018 Share Posted January 10, 2018 This could be a bug in PHP, or it could be a condition that was previously allowed and is no longer. PHP has been getting stricter about some things. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.