-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[J3.7.x] Changes to addStyleSheetVersion, addStyleSheet, addScriptVersion, addScript, existing J3.6.x code is partly broken #12828
Comments
I looked at the code in the
if (!is_array($options) && !is_array($attribs)) should probably be: (in all 4 methods) if (!is_array($options) || !is_array($attribs)) |
Also for the case of B/C of someone extending JDocument and redeclaring the methods:
Notes:
To summarize, $options and $attribs need their old defaults to stay compatible [EDIT] |
Besides the small bug (wrong IF check, that is easy to fix) the only B/C issue that might be a problem (or it may not be, are the default values) of the methods
i was confused with declaration of type for method parameters, which is not our case |
I am sorry i was confused with declaration for variable types for method parameters, I tested, no B/C break Only the bug with PHP warning, if (!is_array($options) && !is_array($attribs)) Something like this should be enough: if (!is_array($options)) |
np, will check that when i have time |
@ggppdk i'm now looking with tiume to your PR description. you are making this: JFactory::getDocument->addStyleSheetVersion('my.css', $version='3.1.1');
JFactory::getDocument->addStyleSheetVersion('my.js', $version='3.1.1'); when it should be this: JFactory::getDocument()->addStyleSheetVersion('my.css', '3.1.1');
JFactory::getDocument()->addScriptVersion('my.js', '3.1.1'); But yes, the issue exists |
Closing since we have a PR to test for it. |
Using $version='3.1.1', is irrelevant, it is about readability and about avoid bugs
I usually do not use this, when only having 2 or 3 parameters
Otherwise the performance difference due to the redudant variable declaration is non-measurable, Example of readability, and avoiding mistakes: $send_result = JFactory::getMailer()->sendMail(
$_from = $data['mailfrom'], $_fromName= $data['fromname'], $_recipient = array($email),
$_emailSubject, $_emailBody,
$_html_mode=true, $_cc=null, $_bcc=null, $_attachment=null,
$_replyto='some@sommmmmm.org', $_replytoname=null
); You could of course declare the variables above the method call, but this means a few extra lines |
sure please test the PR |
doing already, thanks ! |
Steps to reproduce the issue
Try to use:
Expected result
CSS and JS files will be added to the page, together their version string
Actual result
J3.6.x: It works
Staging: Partly broken
Warning: Illegal string offset 'version' in deve/joomla-cms/libraries/joomla/document/document.php on line 550
Warning: Illegal string offset 'version' in devel/joomla-cms/libraries/joomla/document/document.php on line 741
System information (as much as possible)
J3.6.x signatures
J3.7.x signatures
At minimum the existing code of calling the method with the old way needs to work,
and there should be no PHP warnings
It should not be too difficult to detect the old way of calling the methods, and make them work
Additional comments
Also, in the rare case that someone both extends the JDocument, and also overrides the 2 methods, there will be some PHP warnings
The text was updated successfully, but these errors were encountered: