Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9] Warn developers that toolbar.php has been removed #21960

Closed
joeforjoomla opened this Issue Sep 2, 2018 · 59 comments

Comments

Projects
None yet
@joeforjoomla
Copy link
Contributor

joeforjoomla commented Sep 2, 2018

Steps to reproduce the issue

Having an extension that use a:

require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';

Expected result

JToolbarHelper class is loaded

Actual result

Fatal error because the file toolbar.php has been removed

System information (as much as possible)

Joomla 3.9 Alpha

Additional comments

@zero-24

This comment has been minimized.

Copy link
Contributor

zero-24 commented Sep 2, 2018

hmm maybe we need to place a file that is still loading this class with an deprecation notice until 4.0 as this could be counted as a B/C? cc @mbabker @wilsonge ?

@zero-24 zero-24 added this to the Joomla 3.9.0 milestone Sep 2, 2018

@joeforjoomla

This comment has been minimized.

Copy link
Contributor Author

joeforjoomla commented Sep 2, 2018

That would be even better @zero-24

@mbabker

This comment has been minimized.

Copy link
Member

mbabker commented Sep 2, 2018

What is the use case where you are including this file? Before 3.9 it was expected that it was only available in the admin application (and appropriately manually loaded in that case), the class/file was not expected to be used in any other case.

Generally, we don't make file locations a B/C thing, otherwise everything that was namespaced in 3.8 would have to have kept stub files for this exact same reason.

It kind of sounds like your require_once line isn't wrapped in a class_exists('JToolbarHelper') check, which would be the safe thing to do in the first place and have prevented the error in your case.

@laoneo

This comment has been minimized.

Copy link
Member

laoneo commented Sep 2, 2018

It is also recommended to use JLoader to include files which will not crash when the file doesn't exist.

@brianteeman brianteeman added the J3 Issue label Sep 2, 2018

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 3.9.0 milestone Sep 3, 2018

@joeforjoomla

This comment has been minimized.

Copy link
Contributor Author

joeforjoomla commented Sep 3, 2018

I agree but it's not my code, just found it in another extension. So i'm concerned that there is someone out there using a require_once to include that file and use JToolbarHelper in the frontend for example.

@flyingwombats

This comment has been minimized.

Copy link

flyingwombats commented Oct 7, 2018

I am getting this issue when I update 3.8.12 to 3.9beta3 or beta4 and try to use JCE in the backend
2018-10-07 11:42:43 Warning 82.36.19.205 mod_fcgid: stderr: PHP Warning: require_once(/var/www/vhosts/sfdemo.co.uk/nightly.sfdemo.co.uk/administrator/includes/toolbar.php): failed to open stream: No such file or directory in /var/www/vhosts/sfdemo.co.uk/nightly.sfdemo.co.uk/administrator/components/com_jce/controller.php on line 134 Apache error
2018-10-07 11:42:43 Warning 82.36.19.205 mod_fcgid: stderr: PHP Fatal error: require_once(): Failed opening required '/var/www/vhosts/sfdemo.co.uk/nightly.sfdemo.co.uk/administrator/includes/toolbar.php' (include_path='.:/opt/plesk/php/7.2/share/pear') in /var/www/vhosts/sfdemo.co.uk/nightly.sfdemo.co.uk/administrator/components/com_jce/controller.php on line 134

Sandra is not so may be something to do with my setup


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

@joeforjoomla

This comment has been minimized.

Copy link
Contributor Author

joeforjoomla commented Oct 30, 2018

Just a few hours after the release of 3.9 and it happened what i said you some months ago guys #22874

@EArgen

This comment has been minimized.

Copy link

EArgen commented Oct 30, 2018

I just updated to 3.9.0 and am receiving this error on one of my websites. I can't use the admin front end and simply see this error:

An error has occurred.
0 Class 'JToolbarHelper' not found
Return to Control Panel

But when I click the button 'Return to Control Panel' nothing happens. What should I do?

@vz82

This comment has been minimized.

Copy link

vz82 commented Oct 30, 2018

I just updated to 3.9.0 and am receiving this error on one of my websites. I can't use the admin front end and simply see this error:

An error has occurred.
0 Class 'JToolbarHelper' not found
Return to Control Panel

But when I click the button 'Return to Control Panel' nothing happens. What should I do?

Hi there!

Try this workaround:
just replace the index.php in your administrator/includes with the most recent version from the backup you've (of course! ;) ) previously made.

@EArgen

This comment has been minimized.

Copy link

EArgen commented Oct 30, 2018

Hi there vz82. I'll give that a try!

Just so you know, the link you provided doesn't seem to work.

@vz82

This comment has been minimized.

Copy link

vz82 commented Oct 30, 2018

Hi there vz82. I'll give that a try!

Just so you know, the link you provided doesn't seem to work.

Yeah, I've just noticed... :)

Good luck!

@EArgen

This comment has been minimized.

Copy link

EArgen commented Oct 30, 2018

Strange, in my backup folder:
(website\html\administrator\includes)
There is no index.php.

@vz82

This comment has been minimized.

Copy link

vz82 commented Oct 30, 2018

Strange, in my backup folder:
(website\html\administrator\includes)
There is no index.php.

Try (only) administrator/ then...

@EArgen

This comment has been minimized.

Copy link

EArgen commented Oct 30, 2018

That did the trick!
Now of course it's stating that I need to update to Joomla 3.9.0.

Looking closer, this is what the backup file had:

require_once JPATH_BASE . '/includes/toolbar.php';

Whereas this is that same line on the new version:

require_once JPATH_BASE . '/includes/subtoolbar.php';

@mbabker

This comment has been minimized.

Copy link
Member

mbabker commented Oct 30, 2018

#21372 moved the file to an autoloaded class path and namespaced the class, the same as was done for 300 classes in 3.8.

Check to ensure the libraries/classmap.php file matches the 3.9.0 package, that handles ensuring the JToolbarHelper class name is registered to the autoloader and it should be pretty close to impossible for that class name to not be able to be resolved unless there is something overloading what we're pushing into the autoloader (since that is set up very early in the process, before any extension even gets loaded).

@mbabker

This comment has been minimized.

Copy link
Member

mbabker commented Oct 30, 2018

And to be honest I don't think this "class not found" error has anything to do with the original file having been moved. Instead, it seems like we're dealing with an autoloader conflict at a first glance, and if that's the case we need to know more about the operating environments where this issue is coming up (i.e. installed extensions).

@er10077

This comment has been minimized.

Copy link

er10077 commented Oct 30, 2018

Just replace require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';
with
jimport('joomla.html.toolbar');
and it works again

@mbabker

This comment has been minimized.

Copy link
Member

mbabker commented Oct 30, 2018

replace require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';

If you still have that line in a core file after the 3.9 update then the update did not run correctly.

with
jimport('joomla.html.toolbar');

Bad advice. That too is attempting to load a non-existing file (and if you have that file in a 3.x site you've got other problems).

@rkbundy

This comment has been minimized.

Copy link

rkbundy commented Oct 30, 2018

VZ82, you are fantastic! Thank you for the work-around. I don't know how much I'll have to dig into this at night to make sure 3.9.0 is working fully, but at least I can get to the back-end again.

@er10077

This comment has been minimized.

Copy link

er10077 commented Oct 30, 2018

So, the correct way for now is "require_once JPATH_ADMINISTRATOR . '/includes/subtoolbar.php';" right?
I don't have file "toolbar.php" in JPATH_ADMINISTRATOR . '/includes/toolbar.php'; , but jimport('joomla.html.toolbar'); works too. I don't known from where exactly it comes, maybe from /libraries/src/Toolbar/Toolbar.php ?

@laoneo

This comment has been minimized.

Copy link
Member

laoneo commented Oct 30, 2018

Turn on debug mode in the joomla config. What shows the stack trace?

@mbabker

This comment has been minimized.

Copy link
Member

mbabker commented Oct 30, 2018

So, the correct way for now is "require_once JPATH_ADMINISTRATOR . '/includes/subtoolbar.php';" right?

No. That's a completely different file (that was being loaded by the previous administrator/includes/toolbar.php file).

I don't have file "toolbar.php" in JPATH_ADMINISTRATOR . '/includes/toolbar.php'; , but jimport('joomla.html.toolbar'); works too. I don't known from where exactly it comes, maybe from /libraries/src/Toolbar/Toolbar.php ?

jimport('joomla.html.toolbar'); tries to import a file at libraries/joomla/html/toolbar.php. That is where the JToolbar class existed in 2.5 and was moved to libraries/cms/toolbar/toolbar.php at 3.0. It is still a separate file/class from the JToolbarHelper class being discussed here.

@er10077

This comment has been minimized.

Copy link

er10077 commented Oct 30, 2018

ok, thank you. It looks, for now, don't need to include anything to get toolbar working in the frontend of the component. Great work.

Turn on debug mode in the Joomla config. What shows the stack trace?

I don't find anything strange in the stack trace.

@WebSpain

This comment has been minimized.

Copy link

WebSpain commented Oct 30, 2018

I got hit with this on the 3.9 upgrade and it left the Autostand component inaccessible on the front end.

Warning: require_once(/home/findspa/public_html/cars2/administrator/includes/toolbar.php): failed to open stream: No such file or directory in /home/findspa/public_html/cars2/components/com_autostand/autostand.php on line 20

Fatal error: require_once(): Failed opening required '/home/findspa/public_html/cars2/administrator/includes/toolbar.php' (include_path='.:/opt/cpanel/ea-php72/root/usr/share/pear') in /home/findspa/public_html/cars2/components/com_autostand/autostand.php on line 20

I put in the toolbar.php from 3.8.13 and it loads again.......but it seems like Autostand will need to be modded going forward.

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

Tony, thanks for answering. What/where is "the missing toolbar.php file"?

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

My most recent backup is just on my site - which I cannot get to.
I have an older backup downloaded to my PC, but no idea how to use that to restore my website.

Should have gone with wordpress maybe :-)

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

No matter where I click or what I do I see only the same error message.

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

Thank you again for answering, but as you might already have guessed I do not have enough coding knowledge to understand what you are asking me to do. You tell me to "access my website files to restore the fix". Do you mean upload an older version of toolbar.php from my PC by using an ftp uploader?

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

Sadly problem is still there. I have a backup made with Akeeba but no idea how to restore my site with it. Situation is pretty grim...

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

I can't get to any file on the site. Just get the error message. I have the entire site downloaded to my PC, but that is a 1,5year old version.

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

I changed the 0 in the configuration.php file on my PC to 1 and uploaded. Now I have a new error message, saying: No configuration file found and no installation code available. Exiting...

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

@tonypartridge

This comment has been minimized.

Copy link
Contributor

tonypartridge commented Nov 4, 2018

@Jofrid

This comment has been minimized.

Copy link

Jofrid commented Nov 4, 2018

@laoneo

This comment has been minimized.

Copy link
Member

laoneo commented Nov 5, 2018

If you create an empty file in administrator/includes/toolbar.php, does the error not go away? Enable the debug plugin, then a stack trace will be displayed which should guide you to the extension. If no stack trace is shown, then open the site for a test with the protostar template. Some templates have a broken error.php file.

@vz82

This comment has been minimized.

Copy link

vz82 commented Nov 8, 2018

Hi everyone again,

I'm pretty much sure that it was T3 Framework causing the problems (it was updated on November 1 and the upgrade has just succeeded with no errors whatsoever).

Therefore, just make sure to update it BEFORE the Joomla! update (and have a valid backup - of course - just in case :) ).

@FuriousCamel

This comment has been minimized.

Copy link

FuriousCamel commented Nov 9, 2018

This is the stack I get debugging. Uploading the 3.8.13 toolbar.php file did not work... Any help on how to solve (back-up not available)?

Call stack

| Function | Location

1 | () | JROOT/administrator/components/com_cpanel/views/cpanel/view.html.php:36
2 | CpanelViewCpanel->display() | JROOT/libraries/src/MVC/Controller/BaseController.php:672
3 | Joomla\CMS\MVC\Controller\BaseController->display() | JROOT/libraries/src/MVC/Controller/BaseController.php:710
4 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT/administrator/components/com_cpanel/cpanel.php:15
5 | require_once() | JROOT/libraries/src/Component/ComponentHelper.php:382
6 | Joomla\CMS\Component\ComponentHelper::executeComponent() | JROOT/libraries/src/Component/ComponentHelper.php:357
7 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT/libraries/src/Application/AdministratorApplication.php:101
8 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT/libraries/src/Application/AdministratorApplication.php:159
9 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT/libraries/src/Application/CMSApplication.php:195
10 | Joomla\CMS\Application\CMSApplication->execute() | JROOT/administrator/index.php:51

@vz82

This comment has been minimized.

Copy link

vz82 commented Nov 9, 2018

This is the stack I get debugging. Uploading the 3.8.13 toolbar.php file did not work... Any help on how > to solve (back-up not available)?

Have you tried uploading the index.php file (as mentioned earlier)?

@sunilongithub

This comment has been minimized.

Copy link

sunilongithub commented Nov 12, 2018

Hello, I was able to fix this issue with one of my site by editing following file:
/sitefolder/administrator/includes/helper.php

I added following code to the helper.php:

if(!class_exists('JToolbarHelper')) {
require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';
}

above this line in that file:
class JAdministratorHelper

I was able to update it again to latest version. I feel it was caused by poor internet connectivity with the hosting server.

Hope this helps someone here.

@Quy

This comment has been minimized.

Copy link
Contributor

Quy commented Feb 26, 2019

Can this be closed?

@joeforjoomla

This comment has been minimized.

Copy link
Contributor Author

joeforjoomla commented Feb 26, 2019

Yes, closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.