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

Fix Cannot use a scalar value warning #15600

Merged
merged 1 commit into from Apr 27, 2017
Merged

Fix Cannot use a scalar value warning #15600

merged 1 commit into from Apr 27, 2017

Conversation

weeblr
Copy link
Contributor

@weeblr weeblr commented Apr 26, 2017

Per #15548, multiple Cannot use a scalar value as an array warning are showing on many sites after update to Joomla 3.7

Pull Request for Issue # 15448.

Summary of Changes

Removed test on $attribs being an array. Issue analysis by George Wilson is here: #15548 (comment)

Testing Instructions

On site showing those warnings, applying the patch should stop them, and restored functionalities that may be broken (Some Payplans features stop working) because the corresponding javascript file is actually not inserted in the page.

Expected result

Actual result

Documentation Changes Required

Per #15548, multiple Cannot use a scalar value as an array warning are showing on many sites after update to Joomla 3.7
@wilsonge wilsonge merged commit a42db63 into joomla:staging Apr 27, 2017
@wilsonge wilsonge added this to the Joomla 3.7.1 milestone Apr 27, 2017
@wilsonge
Copy link
Contributor

Thanks for doing this whilst I was out!

@Quy
Copy link
Contributor

Quy commented Apr 29, 2017

@weeblr @wilsonge These 2 functions stylesheet() and script() are similar yet the following lines are different. Should they be the same since there is a pending pr #15641 to fix a related issue?

https://github.com/weeblr/joomla-cms/blob/ded3c883f6cd753649da86686b28ac02cfdc47b3/libraries/cms/html/html.php#L604

https://github.com/weeblr/joomla-cms/blob/ded3c883f6cd753649da86686b28ac02cfdc47b3/libraries/cms/html/html.php#L676

@wilsonge
Copy link
Contributor

The only difference is the variable name?

@Quy
Copy link
Contributor

Quy commented Apr 29, 2017

Correct. Should line 604 be if (!is_array($options))?

@Quy
Copy link
Contributor

Quy commented Apr 29, 2017

If yes, then #15641 can be closed.

@weeblr
Copy link
Contributor Author

weeblr commented Apr 29, 2017

@wilsonge @Quy They should NOT be the same I think. The previous, deprecated methods signatures are different.
stylesheet(file, attribs, relative, pathOnly, detectBrowser, detectDebug)
vs
script(file, framework, relative, pathOnly, detectBrowser, detectDebug)

For stylesheet, we test only the second parameter ($attribs) because the first ($options) was also an array in both old and new signature.

As you can see in the next lines, the code to handle $attribs and $options is not the same.

@Quy
Copy link
Contributor

Quy commented Apr 29, 2017

@weeblr @wilsonge In stylesheet, attribs would be assigned to options from the old to the new so you would have to test for $options?

@weeblr
Copy link
Contributor Author

weeblr commented Apr 29, 2017

No, it's about how the method is called.
stylesheet() can be called either with:

  • old syntax: stylesheet(string, array, bool,...)
  • new syntax: stylesheet(string, array, array)

So the way to detect whether the call is with the new or old syntax is by looking at the 3rd parameter. If an array, it's the new syntax. If not an array, then it 's the old syntax.
The variable names are not what matters, it's more about the ordering.

rdeutz pushed a commit to joomlajenkins/joomla-cms that referenced this pull request May 1, 2017
Per joomla#15548, multiple Cannot use a scalar value as an array warning are showing on many sites after update to Joomla 3.7
@tracylee3124
Copy link

screen shot 2017-05-01 at 16 46 42
We just updated to Joomla! 3.7.0 and I started getting this warning message on the panel that allows you to upload documents and add a link to the page. I was having trouble uploading files using that.

I am not sure what I should edit to fix this issue.

Can someone give some advice?

Thanks,
Tracy


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

@weeblr
Copy link
Contributor Author

weeblr commented May 1, 2017

@tracylee3124 Maybe best is to wait until a new Joomla release is available? I suspect there might be one coming, though @wilsonge or @rdeutz would know better.

If you don't want to wait, you should apply the modification displayed on the "Files changed" tab of this page. The link to there is: https://github.com/joomla/joomla-cms/pull/15600/files

Be sure to always be able to restore any file you modify this way, in case something goes wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants