Error installing library Topic is solved
Moderators: ooffick, General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Error installing library
I recently converted from Joomla 3.10 to Joomla 4.2.6
When I install a library, I always get the error
Cannot declare class XXXXInstallerScript because the name is already in use
Screen shot attached. Clearing all caches always fixes it
When I install a library, I always get the error
Cannot declare class XXXXInstallerScript because the name is already in use
Screen shot attached. Clearing all caches always fixes it
You do not have the required permissions to view the files attached to this post.
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
Update. The odd thing is that if I clear all caches before doing the install, it fails with the error above. When I then clear caches and reinstall, it works.
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
The zip installs without problems on Joomla 3.10.11
- toivo
- Joomla! Master
- Posts: 17442
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: Error installing library
Which particular library is it? Are you sure it is compatible with Joomla 4?
Toivo Talikka, Global Moderator
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
It's my own library, and it runs fine under Joomla 4 once it's installed. The only problem I see is the install problem referenced here.
- Per Yngve Berg
- Joomla! Master
- Posts: 30935
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: Error installing library
Mod. Note: Relocated the topic to the Coding Forum.
- ceford
- Joomla! Hero
- Posts: 2677
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: Error installing library
Looks like you are using a custom installer script that does all the work usually done from index.php. Joomla 3 and 4 install.php scripts look quite different, like this:
Where the class contains various functions called by the installer (the Joomla one). I don't know how you might fix the problem! If the library gets installed and works it may be best to leave it alone.
Code: Select all
\defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
[or various other classes needed for installation]
class com_fooInstallerScript
{
}
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
Thanks. Do you have a pointer to the differences in installer scripts between J3 and J4?
My script is quite simple. I want to display a message with the component version and to delete obsolete files. All of that does work after I clear the cache, so it's not a huge deal.
My script is quite simple. I want to display a message with the component version and to delete obsolete files. All of that does work after I clear the cache, so it's not a huge deal.
- ceford
- Joomla! Hero
- Posts: 2677
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: Error installing library
I can't really help, other than point you to libraries/src/Installer/InstallerAdapter.php line 961 where you are loading a file containing a class name that is already loaded. You probably know that. Look at the script files in some of the administrator components - mostly you only need preflight and postflight. What does your script file do?
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
Thanks, I'll look there. It just displays the installed version and deletes obsolete files.
-
- Joomla! Intern
- Posts: 56
- Joined: Mon Dec 16, 2013 2:29 pm
Re: Error installing library
Good suggestion to look at other components.
Poking around components, I found nothing unusual, but I did find something looking at library install scripts. Few libraries that I use have them, but Regular Labs does. And they wrap their class with a check to see that the class isn't already defined. When I did the same thing, the problem went away, and it seemed to run the install script correctly.
I'm guessing that there's something in library install where the script can get loaded twice, but I'm not going to debug it.
Thanks for the help.
Poking around components, I found nothing unusual, but I did find something looking at library install scripts. Few libraries that I use have them, but Regular Labs does. And they wrap their class with a check to see that the class isn't already defined. When I did the same thing, the problem went away, and it seemed to run the install script correctly.
I'm guessing that there's something in library install where the script can get loaded twice, but I'm not going to debug it.
Thanks for the help.