J3 Issue ?
avatar glenatron
glenatron
14 Jun 2019

Steps to reproduce the issue

Create a Component in accordance with the J3.x development tutorial with an sql folder and a simple install.mysql.utf8.sql but no numbered updates.

Expected result

The SQL in the install.mysql.utf8.sql is run and there is no error raised.

Actual result

A large error is raised, with the error stack ending in line 1085 of Install.php - which looks like this:

$files = str_replace('.sql', '', \JFolder::files($this->getPath('extension_root') . '/' . $schemapath, '\.sql$')); usort($files, 'version_compare');

My suspicion is that $files contains no results, so there is nothing to sort.

Also the installer sql is not run in my case, but that may be completely unrelated.

System information (as much as possible)

Running on a WAMP stack on Windows, but it seems plausible that this is going to be a reasonably common problem.

I did have the update section in my config xml, which may have been a bad thing when there weren't any files in that folder yet:
<!update> <schemas> <schemapath type="mysql">sql/updates/mysql</schemapath> </schemas> </update -->

Still I would expect this to be handled in a calmer way.

Additional comments

I have worked around it with a little hedging on that usort call for now, but that is probably not the best solution.

avatar glenatron glenatron - open - 14 Jun 2019
avatar joomla-cms-bot joomla-cms-bot - change - 14 Jun 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Jun 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Jun 2019
Title
Installing a component with only an installation sql file raises a big error message.
Installing a component with only an installation sql file raises a big error message
avatar franz-wohlkoenig franz-wohlkoenig - edited - 14 Jun 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Jun 2019
Labels Added: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 14 Jun 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 14 Jun 2019
Status New Information Required
avatar ReLater
ReLater - comment - 14 Jun 2019

Now I see:

Red warning message but no other messages(!)

Warning : usort() expects parameter 1 to be array, string given in /libraries/src/Installer/Installer.php on line 1085
Warning : end() expects parameter 1 to be array, string given in /libraries/src/Installer/Installer.php on line 1098
{"success":true,"message":null,"messages":{"warning":["JFolder: :files: Path is not a folder. Path: \/administrator\/components\/com_helloworld\/sql\/updates\/mysql"],"message":["Installation of the component was successful."]},"data":{"redirect":"\/administrator\/index.php?option=com_installer&view=install"}}

The extension is installed now.

Reload the page: or navigate to another one:

  • You see the "correct" message from the message queue that should be displayed before reload (immediately after installation):
Warning
JFolder: :files: Path is not a folder. Path: /administrator/components/com_helloworld/sql/updates/mysql

Pro: Thus it's somehow an issue from my point of view even if the extension package manifest is misconfigured because the redirect/page reload is suppressed.

Their should be at least an additional message for users that the extension has been installed.

Irritating.

Contra: On the other hand I would say it's the job of the developer to avoid such errors before releasing an extension and a developer should be able to understand the red message. Not a Joomla core issue.

Contra would rule for me and I would close the issue.

After installation

14-06-_2019_21-38-01

After page reload

14-06-_2019_21-41-44

avatar glenatron
glenatron - comment - 14 Jun 2019

If nothing else, a more informative exception ( or performing some validation on the component xml file ) would make the problem a lot easier to troubleshoot- figuring out how to construct a component is pretty tricky even as an experienced developer and supporting people in doing that is probably a positive for the Joomla ecosystem.

avatar HLeithner
HLeithner - comment - 15 Jun 2019

@glenatron it woild be appreciated if you write a pr that make the install process smoother or bring us better error handling

avatar richard67
richard67 - comment - 16 Jun 2019

This issue here could be related to an issue which the patchtester component had, see comment here: joomla-extensions/patchtester#186 (comment).

avatar glenatron
glenatron - comment - 17 Jun 2019

@HLeithner sure, is the best way to raise the message to use application->enqueueMessage($msg, 'error'); or is something else more correct in this circumstance?

Can confirm that failing to run the SQL installer file was me messing up the markup of my config file, so that is not relevant to this message at all.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 17 Jun 2019

@infograf768 can the Issue be closed?

avatar HLeithner HLeithner - change - 17 Jun 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-06-17 11:41:22
Closed_By HLeithner
avatar HLeithner
HLeithner - comment - 17 Jun 2019

@glenatron enqueue a message would be enough so if the developer test his component at least once he should see the problem.

I'm closing this. You can reference this issue in your PR.

avatar HLeithner HLeithner - close - 17 Jun 2019
avatar ReLater
ReLater - comment - 17 Jun 2019

Maybe you're right and I don't understand your thoughts but there is already a correct message in the queue as you can see in the red error:

{"success":true,"message":null,"messages":{"warning":["JFolder: :files: Path is not a folder. Path: /administrator/components/com_helloworld/sql/updates/mysql"],"message":["Installation of the component was successful."]},"data":{"redirect":"/administrator/index.php?option=com_installer&view=install"}}

but it's not displayed. From my point of view the whole routine should stop if $files is not an array because the whole following db query is broken then.

https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Installer/Installer.php#L1098

avatar HLeithner
HLeithner - comment - 17 Jun 2019

2 possible ways, stop the installation or let the installer ignore the missing sql file.

avatar ReLater
ReLater - comment - 17 Jun 2019

Because I prefer to learn coding "the hard way" I would leave it as ist is. See my "Contra" in #25202 (comment)
Why should Joomla react friendly here? The extension is wrongly configured. The red message contains all necessary informations for developers and more helpful informations than the message queue can provide.

Add a Comment

Login with GitHub to post a comment