Joomla-cms: Backward compatible issue with JLoader change in Joomla 3.6.0

Created on 13 Jul 2016  Â·  28Comments  Â·  Source: joomla/joomla-cms

First of all, I am sorry for could not test my extensions with Joomla 3.6.0 before it was released.

Steps to reproduce the issue

After updating to Joomla 3.6.0, our customers reported this fatal error with my extension Events Booking

Fatal error: Cannot redeclare EventbookingBuildRoute() (previously declared in /home1/alamode1/public_html/components/com_eventbooking/router.php:16) in /home1/alamode1/public_html/components/com_eventbooking/router.php on line 16

Expected result

Everything works well as in Joomla 3.5.1

Actual result

Fatal error as stated above

Additional comments

I haven't had a enough time to find out the root of the error yet. However, I think it is related to this PR https://github.com/joomla/joomla-cms/pull/9541

  1. My component use JLoader::registerPrefix method for auto-loading component classes
JLoader::registerPrefix('Eventbooking', JPATH_BASE . '/components/com_eventbooking');
  1. Joomla routing tries to find the class EventbookingRouter for building SEF urls. As the router in the component still use old format (not class base routing), the class doesn't exist and it seems with the change in JLoader , the file components/com_eventbooking/router.php is included twice and it causes the fatal error.

For now, I fix the issue by changing component router code to use class

class EventbookingRouter extends JComponentRouterBase
{
         public function build(&$query)
         {
         }

        public function parse(&$segments)
        {
        }
}
No Code Attached Yet

All 28 comments

That's probably the cause but I wouldn't consider it a backward
compatibility issue. It's indeed an unwanted side effect and it really
only works with the controller.php and router.php files because those would
possibly have a class matching a registered prefix to the autoloader; maybe
the component's entry point file too if you had some class like
EventbookingEventbooking.

On Tuesday, July 12, 2016, Tuan Pham Ngoc [email protected] wrote:

First of all, I am sorry for could not test my extensions with Joomla
3.6.0 before it was released.
Steps to reproduce the issue

After updating to Joomla 3.6.0, our customers reported this fatal error
with my extension Events Booking

Fatal error: Cannot redeclare EventbookingBuildRoute() (previously
declared in
/home1/alamode1/public_html/components/com_eventbooking/router.php:16) in
/home1/alamode1/public_html/components/com_eventbooking/router.php on line
16

Expected result

Everything works well as in Joomla 3.5.1
Actual result

Fatal error as stated above
Additional comments

I haven't had a enough time to find out the root of the error yet.
However, I think it is related to this PR #9541
https://github.com/joomla/joomla-cms/pull/9541

  1. My component use JLoader::registerPrefix method for auto-loading
    component classes

JLoader::registerPrefix('Eventbooking', JPATH_BASE . '/components/com_eventbooking');

  1. Joomla routing tries to find the class EventbookingRouter for
    building SEF urls. As the router in the component still use old format (not
    class base routing), the class doesn't exist and it seems with the change
    in JLoader , the file components/com_eventbooking/router.php is included
    twice and it causes the fatal error.

For now, I fix the issue by changing component router code to use class

class EventbookingRouter extends JComponentRouterBase{ public function build(&$query) { } public function parse(&$segments) { }}

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/issues/11088, or mute the thread
https://github.com/notifications/unsubscribe/AAWfoayBoaRJhbjCpvVWj3z-jyZcCbktks5qVF0XgaJpZM4JLCHb
.

Thanks Michael for your response. For my extensions, the only affected file is router.php, it is an easy and quick fix, so I am not worry about it. I just reported it here in case someone else has same issue could see the reason and can address it.

Honestly the only fix is reverting that pull request and removing the
ability to autoload files without being nested in a directory. Depends how
strongly people feel about it I guess.

On Tuesday, July 12, 2016, Tuan Pham Ngoc [email protected] wrote:

Thanks Michael for your response. For my extensions, the only affected
file is router.php, it is an easy and quick fix, so I am not worry about
it. I just reported it here in case someone else has same issue could see
the reason and can address it.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/issues/11088#issuecomment-232250057,
or mute the thread
https://github.com/notifications/unsubscribe/AAWfoUcZpk6spkdMNXsy8sqt_NGPMX_Lks5qVGGFgaJpZM4JLCHb
.

I think it will only happens with components use JLoader::registerPrefix to autoload component's classes like in my case. Joomla core components don't use it (?), so hopefully, there are not many extensions get this issue

Lets leave this open for a few weeks in case anyone else reports it. If not then we can close this


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11088.

+1
+1
+1

3 so far today :)

I can confirm this issue loading duplicated routers.

The main issue is that router is checking things based in routers' class names:
https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/router/site.php#L717

That's checking if a class exists but old routers are based in functions so it tries to require the file.

Also the loader is using include here:
https://github.com/joomla/joomla-cms/blob/staging/libraries/loader.php#L599

Switching that to include_once fixed the issue here but I don't know if that can cause some side effects (In fact I think require_once would be better there because if a class is not loaded a bigger issue will happen?)

So as I see it there are 2 possible solutions:

  • Do the function verification that is done here before the getComponentRouter() require_once
  • Switch that include in JLoader to include_once (or require_once if you have time to fix further issues)

Hi everyone. I can confirm the same issue as i was testing the Joomla 3.6 upgrade on my demo site:

Fatal error: Cannot redeclare EventbookingBuildRoute() (previously declared in /var/www/vhosts/demo.rwmbeta.com/public_html/components/com_eventbooking/router.php:16) in /var/www/vhosts/demo.rwmbeta.com/public_html/components/com_eventbooking/router.php on line 374


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11088.

@rwestpga For Events Booking, please update to 2.8.1 and it will work well

Setting to needs review


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11088.

That's probably the cause but I wouldn't consider it a backward
compatibility issue

Honestly the only fix is reverting that pull request and removing the
ability to autoload files without being nested in a directory. Depends how
strongly people feel about it I guess.

I guess people dont feel strongly about it based on the activity - I strike to close this?

Yes, we should close this issue. I had converted all of my extensions to use class base router, so it is no longer an issue anymore. Let's move forward!

On preview I get:
Cannot redeclare EventbookingBuildRoute() (previously declared in /home/franklinhighscho/public_html/components/com_eventbooking/router.php:16) in /home/franklinhighscho/public_html/components/com_eventbooking/router.php on line 357

Has there been a fix discovered? Thanks!

@nmemory Update your site to latest version of Events Booking and the error will be gone

If you could not afford to purchase latest version to update, submit a support ticket and we will help modifying the router file to get it works with latest version of Joomla

Thank you. I'm new here... where do I submit a support ticket?

Go to http://joomdonation.com/support-tickets.html to submit ticket (You need to register for an account on our website to submit ticket)

ok, thank you!

I submitted a ticket. What is the best way to get the response? Do I sit here and check where the ticket was posted or watch my email? The response time said 24 hours.

Again, thanks!

Asked you for more information via support ticket (there should be notification sent to you already). Please use our support tickets system to reply, don't submit more comment here.

Hi there,

This is what i get after updating joomla from 3.6.2 to 3.6.4:
Fatal error: Cannot redeclare EventbookingBuildRoute() (previously declared in /home/topvriendj/domains/wegenercoaching.nl/public_html/components/com_eventbooking/router.php:16) in /home/topvriendj/domains/wegenercoaching.nl/public_html/components/com_eventbooking/router.php on line 358

Who can help me...

Who can help me...

If you read the full thread in this issue, its full of things that can help you!

Update your site to latest version of Events Booking and the error will be gone

and

Go to http://joomdonation.com/support-tickets.html to submit ticket (You need to register for an account on our website to submit ticket)

Most probably you only need to update the component ... and you have your fix ...

I did try to update but it doesnt work ... :(

I did try to update but it doesnt work ... :(

Then you need to contact @joomdonation and seek support for their extension. Support for 3rd party extensions is not available in the Joomla CMS Issue tracker.

Go to http://joomdonation.com/support-tickets.html to submit ticket (You need to register for an account on our website to submit ticket)

I'm not using this component ... could I deinstall / remove this item in Joomla or is this not possible ?
event_booking

BACKUP YOUR SITE then select the event booking items and click uninstalll

I did try to update but it doesnt work ... :(

A general comment about paid extensions , many have an update URL
ok, but the update URL, will not work without a subscription

  • you will probably need to renew your subscription and then login into the website, and then try to update
  • or after you renew your subscription, just download manually after you subscribe and upgrade

i do not know more i do use this component

It is fixt, I did uninstall correctly and it works fine again!! Thank you all, I really appreciate you fast replays :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartijnMaandag picture MartijnMaandag  Â·  6Comments

Didldu-Florian picture Didldu-Florian  Â·  4Comments

B3nito picture B3nito  Â·  5Comments

PhilETaylor picture PhilETaylor  Â·  3Comments

uglyeoin picture uglyeoin  Â·  5Comments