I created my first snippet as described in
another thread. I found that it was executing twice, but the problem wasn't anything I had done.
I have a home page resource based on a template. The template has a tag to call my snippet. The snippet was always executing twice. I used the Debug snippet by Oleg Pryadko to see if it would reveal any issues. It did report the following:
(ERROR @ /index.php)[OnWebPagePrerender]
Notice: Undefined index: browser in /home/path/core/cache/includes/elements/modplugin/6.include.cache.php on line 201
Notice: Undefined index: browser in /home/path/core/cache/includes/elements/modplugin/6.include.cache.php on line 131
Notice: Undefined index: browser in /home/path/core/cache/includes/elements/modplugin/6.include.cache.php on line 131
I opened the cache file and saw it's the Mobile Detection plugin by Zuriel Andrusyshyn.
Disabling that plugin causes my snippet to only execute once, as it should. My problem is solved.
For the purposes of this thread, the point is that when that error is caught, my snippet only runs once. If error reporting is off (as set in the Debug snippet), the my snippet runs twice! I think this is a bug that could be occurring in a lot of sites but admins just aren't aware of it if they aren't checking the log. The issue isn't with the faulty plugin, but that an unreported exception seems to cause an unrelated snippet to execute twice.
As to the Mobile Detection plugin, and I'll post this here because it may be related, I dunno... Line 201 doesn't reference 'browser', but line 131 does. (I'm wondering if some other script is in cache and then replaced?)
This plugin adds a cookie called 'browser' and then attempts to retrieve it at line 131 with "
return $_COOKIE['browser'];". The cookie is supposed to be set the first time the plugin is executed, as a marker to identify the browser as mobile or desktop. If the cookie is already there the plugin doesn't do anything more, but if it's not there it sets the cookie. All OK except that it's throwing an error which is
explained here. I'll try to send a note to Zuriel Andrusyshyn. (See EDIT below)
In conclusion, there is a plugin error which seems to have exposed a Revo error. If someone here thinks this is all accurate then I'll report it in the tracker - another first-time event for me here.
Thanks!
(EDIT)
Apparently the cookie error in the plugin had already been
reported, but my focus here is the snippet double-execution problem which is not related to any specific plugin or snippet.
[ed. note: captainstarbuck last edited this post 11 years, 4 months ago.]