lat9 / usu

Ultimate SEO URLs for Zen Cart
GNU General Public License v3.0
1 stars 5 forks source link

v3.0.0-beta2: PHP Fatal Error when "Enable automatic redirects" is set to true #13

Closed lat9 closed 5 years ago

lat9 commented 5 years ago

This turned out to be a chicken/egg "thing" between USU's observer class and main processing class.

When automatic-redirects are enabled, the main class' construction creates the alternate form of the current link's URL and, if different from what's supplied by the access, performs that redirect. If a page (like login) isn't in the list of pages to be handled by USU, the processing calls zen_href_link to create the 'normal' Zen Cart URL.

USU's observer class is (currently) enabling observation for the notification thrown by the zen_href_link function prior to its instantiation of its processing class. That results in a debug-log similar to:

PHP Fatal error:  Uncaught Error: Call to a member function href_link() on null in /home/xxx/public_html/includes/classes/observers/UsuObserver.php:52

Restructuring the observer class to instantiate its base class first so that the observer's instance of usu is available for the notification corrects the issue.