? ? ? Pending

User tests: Successful: Unsuccessful:

avatar BrainforgeUK
BrainforgeUK
5 Oct 2022

Such warnings cause com_installer to raise a JSON error because it messes up the Ajax response.

Pull Request for Issue # .

Summary of Changes

Supress such warnings by adding @ to simplexml_load_file($file)

Testing Instructions

Install an extension with duplicate client attributes
<extension type="module" client="administrator" method="upgrade" version="3.1" client="administrator" position="cpanel">
Installs OK.

Try to install any other extension and get JSON error.
For some reason the installer runs through all the existing manifest files and hits the problem when it meets the previously installed extension.

Actual result BEFORE applying this Pull Request

Get JSON parse error

Expected result AFTER applying this Pull Request

Not a problem with extension being installed so would not expect an error.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar BrainforgeUK BrainforgeUK - open - 5 Oct 2022
avatar BrainforgeUK BrainforgeUK - change - 5 Oct 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Oct 2022
Category Libraries
avatar Fedik
Fedik - comment - 5 Oct 2022

I have tested this item successfully on e9dfc25


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

avatar Fedik Fedik - test_item - 5 Oct 2022 - Tested successfully
avatar laoneo
laoneo - comment - 5 Oct 2022

Honestly I do not like to supress a warning. I would rather fix the code which produces the XML. Or do a propper error handling as PHP supports this.

avatar Fedik
Fedik - comment - 5 Oct 2022

In general I also would prefer libxml_use_internal_errors, but for this particular case it is fine with @, I think.
Because we just ignore broken XML here.

avatar laoneo
laoneo - comment - 5 Oct 2022

Why should we do here an exception? When a manifest file can't be loaded, the developer needs to know why. Otherwise it would be very frustrating, when the extension namespace is not loaded and no error is shown.

avatar BrainforgeUK
BrainforgeUK - comment - 5 Oct 2022

The trouble with this error is that it is with a previously installed extension not the extension being installed.
Causes confusion as the developer on the extension being installed gets the blame!

avatar Fedik
Fedik - comment - 5 Oct 2022

Why should we do here an exception?

// When invalid, ignore
if (!$xml) {
continue;
}

The PR is fine for what it is.

avatar laoneo
laoneo - comment - 5 Oct 2022

@Fedik you didn't understand or don't want to understand. But when a manifest file has wrong XML code which can't be parsed, then this should not be silently ignored. There must be any feedback.

avatar Fedik
Fedik - comment - 5 Oct 2022

this should not be silently ignored

It already designed to be silently ignored.

If you want to change this then it is totally different issue.
To achieve what you asked someone should review whole namespacemap.php thing.
And we probably cannot change it in 4x.

avatar laoneo
laoneo - comment - 5 Oct 2022

All I'm asking for is to properly catch the error how it is designed in PHP land and not to hide it. I was not talking about any refactoring at all.

avatar Fedik
Fedik - comment - 5 Oct 2022

For me it is good how it done, it can be improved later.

avatar HLeithner
HLeithner - comment - 6 Oct 2022

@laoneo it's a bit unfair to request to fix this if you did more or less the same 5 month ago #37595

anyway never use @ please use the 3rd parameter LIBXML_NOWARNING for now.

                $xml = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOWARNING);

The complete function doesn't expect any error which is really strange why we are so lazy here... maybe it's too critical to create the namespace map compared to the problem when a extension is broken? Any way we need to report error somewhere maybe in the JLOG?

avatar BrainforgeUK
BrainforgeUK - comment - 6 Oct 2022

As I suspected this PR raises more questions - which should be dealt with elsewhere.

Why was the error in the first extension not spotted and the installation failed?
Instead the error does not occur until another extension, from another developer, is installed.
The 2nd developer gets blamed and not the 1st developer!

This fix solves the immediate problem.

Anyway using LIBXML_NOWARNING sounds like a good idea.
Will implement shortly.

avatar BrainforgeUK BrainforgeUK - change - 6 Oct 2022
Labels Added: ? ?
avatar Fedik
Fedik - comment - 6 Oct 2022

@BrainforgeUK can you please check whether this work:

$xml = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOERROR |  LIBXML_ERR_NONE);

Cannot currently check on my own. Duplicated attribute is an Error in XML, not Warning.

avatar BrainforgeUK
BrainforgeUK - comment - 6 Oct 2022

No need for LIBXML_ERR_NONE, on its own it did not help.
LIBXML_NOERROR achieves the objective of avoiding the JSON error.

avatar Fedik
Fedik - comment - 7 Oct 2022

I have tested this item successfully on 129394c

With LIBXML_NOERROR also works


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

avatar Fedik Fedik - test_item - 7 Oct 2022 - Tested successfully
avatar viocassel
viocassel - comment - 10 Oct 2022

I have tested this item successfully on 129394c


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

avatar viocassel viocassel - test_item - 10 Oct 2022 - Tested successfully
avatar Fedik Fedik - change - 11 Oct 2022
Status Pending Ready to Commit
avatar Fedik
Fedik - comment - 11 Oct 2022

r2c


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

avatar HLeithner HLeithner - change - 15 Oct 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-10-15 08:42:52
Closed_By HLeithner
Labels Added: ?
avatar HLeithner HLeithner - close - 15 Oct 2022
avatar HLeithner HLeithner - merge - 15 Oct 2022
avatar HLeithner
HLeithner - comment - 15 Oct 2022

thanks

Add a Comment

Login with GitHub to post a comment