OC 2.3.0.2 + Journal 2 + php 7.3 - Cannot declare class Mobile_Detect

#1
It is used already by journal2_cache.php - require_once(DIR_SYSTEM . 'journal2/lib/Mobile_Detect.php');
so include_once(DIR_SYSTEM . 'library/Mobile_Detect/Mobile_Detect.php'); leads to error 500
The error remains even if all journal cache is off and cache is cleared (by journal menu).
Can this be solved?
(site is magbor.com)
 
#3
A 500 error can mean anything and unless you post the entire error, unfortunately we can't help you. At least post the entire error message.
in error_log:
PHP Fatal error: Cannot declare class Mobile_Detect, because the name is already in use in /home/magborco/public_html/system/library/Mobile_Detect/Mobile_Detect.php on line 23
when enabling lscache - the result in front is error 500
 

serpent_driver

Well-Known Member
#4
You have already given yourself the answer to your issue. Journal 2 uses a class with the same name as in the LScache plugin and this is not allowed or causes the error. The functionality for detecting devices works differently in Journal than in the LScache plugin and regularly leads to conflicts. You can try temporarily disabling the "Separate View for Mobile Device" feature in the cache plugin, which will probably fix the conflict, but then the device detection in Journal will no longer work.
 

AndreyPopov

Well-Known Member
#5
It is used already by journal2_cache.php - require_once(DIR_SYSTEM . 'journal2/lib/Mobile_Detect.php');
so include_once(DIR_SYSTEM . 'library/Mobile_Detect/Mobile_Detect.php'); leads to error 500
The error remains even if all journal cache is off and cache is cleared (by journal menu).
Can this be solved?
Journal2 and LScache plugin use same Mobile_Detect library.

then delete or rename
/home/magborco/public_html/system/library/Mobile_Detect/Mobile_Detect.php

or in file
/catalog/controller/extension/module/lscache.php

comment
PHP:
// include_once(DIR_SYSTEM . 'library/Mobile_Detect/Mobile_Detect.php');
 
Last edited:
#6
Journal2 and LScache plugin use same Mobile_Detect library.

then delete or rename
/home/magborco/public_html/system/library/Mobile_Detect/Mobile_Detect.php

or in file
/catalog/controller/extension/module/lscache.php

comment
PHP:
// include_once(DIR_SYSTEM . 'library/Mobile_Detect/Mobile_Detect.php');
Thank you very much for answering the question!
I tried first your second idea and commented the "include_once" line in lscache.php but this leads to error 500 again. If you are interested in the error I can post it.
But your first proposal works for now without any errors: before installing from the Modules menu I deleted the file /system/library/Mobile_Detect/Mobile_Detect.php and in headers, lscache is presented. www.magbor.com
The site is not faster at all for now, but I hope to find ways to make it better. The main thing is that it is fully functional and has no problems.
I fear only that the Mobile_Detect.php which Journal2 uses is an older version @version 2.8.25 than the one in lscache @version 2.8.34. Is that a problem? Thank you again for your efforts.
 

AndreyPopov

Well-Known Member
#7
I fear only that the Mobile_Detect.php which Journal2 uses is an older version @version 2.8.25 than the one in lscache @version 2.8.34. Is that a problem? Thank you again for your efforts.
not fear. no problem.

Journal decide what mobile or no. lscache only cache.
if Journal says - mobile, lscache mark copy of page as mobile
 
#8
not fear. no problem.

Journal decide what mobile or no. lscache only cache.
if Journal says - mobile, lscache mark copy of page as mobile
I see I will need a lot of help to get it working right.. :) Too many questions -

do I need to uncomment a separate mobile view... and so on

Thank you for your cooperation, I appreciate it much! If I am sure what to ask, I will place a question again
 

serpent_driver

Well-Known Member
#10
@magbor
Unfortunately, what @AndreyPopov says is not entirely true. The LScache plugin not only caches. The cache varies (rewrite rules in .htaccess) are the counterpart to the PHP class Mobile_Detect. If you need device detection for Mobile View, then these Cache Varies in .htaccess are mandatory. Otherwise the cache plugin does not know what a mobile device is and the display will be incorrect.
 

AndreyPopov

Well-Known Member
#11
@magbor
The LScache plugin not only caches.
really? are you sure?



@magbor
If you need device detection for Mobile View, then these Cache Varies in .htaccess are mandatory. Otherwise the cache plugin does not know what a mobile device is and the display will be incorrect.
LScache use COOKIES for this and .htaccess rewrite rules only nessesary for Bots and devices (UAs) that not accept cookies!
 
Top