? Success

User tests: Successful: Unsuccessful:

avatar zero-24
zero-24
9 May 2014

Tracker:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=32642

replace: #2463

How to test

1. way

1) BE --> Content --> Article Manager --> Add New Article --> Tab: Publishing
2) make sure the calendar works ok.
3) add into this file at this place: https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/html.php#L959

$attribs = 'example';

4) refresh the page
5) make sure that the calendar is broken
6) apply patch
7) redo 3)
8) refresh the page
9) make sure that all works as bevor

Alternative way:

Code: <?php echo JHtml::calendar(null, 'test', 'id-test', '%Y-%m-%d', 'class="blah" readonly="true"'); ?>

Insert this code into a view or index.php of your template (i.e. some php file that is viewable). Note the 3 php errors. Apply the PR. Errors go away.

avatar zero-24 zero-24 - open - 9 May 2014
avatar zero-24 zero-24 - change - 9 May 2014
Title
Warning if string is passed as $attrib
[#32642] Warning if string is passed as $attrib
avatar elkuku
elkuku - comment - 9 May 2014

Using the "alternative way"

echo JHtml::calendar(null, 'test', 'id-test', '%Y-%m-%d', 'class="blah" readonly="true"');

I get:
before:

Warning: Illegal string offset 'class' in .../libraries/cms/html/html.php on line 965
Warning: Illegal string offset 'class' in .../libraries/cms/html/html.php on line 966

and after:

Notice: Undefined variable: readonly in .../libraries/cms/html/html.php on line 1022
Notice: Undefined variable: disabled in .../libraries/cms/html/html.php on line 1022

No big deal :wink:

I would also opt for a type hint (even if this breaks b/c again...)

avatar wilsonge
wilsonge - comment - 10 May 2014

I don't see the point in this PR anyhow. Attribs has a docblock of array since 2011 - I don't really see the need to all this stuff just to keep compatibility with 1.5

avatar zero-24 zero-24 - change - 10 May 2014
The description was changed
Title
Warning if string is passed as $attrib
[#32642] Warning if string is passed as $attrib
Description <p>Tracker:<br><a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_id=8103&amp;tracker_item_id=32642">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_id=8103&amp;tracker_item_id=32642</a></p> <p>replace: <a href="https://github.com/joomla/joomla-cms/pull/2463" class="issue-link" title="HTML Calendar: Accept a string for the $attrib parameter">#2463</a></p> <p>Tracker:<br><a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_id=8103&amp;tracker_item_id=32642">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_id=8103&amp;tracker_item_id=32642</a></p> <p>replace: <a href="https://github.com/joomla/joomla-cms/pull/2463" class="issue-link" title="HTML Calendar: Accept a string for the $attrib parameter">#2463</a></p> <h2>How to test</h2> <h3>1. way</h3> <p>1) BE --&gt; Content --&gt; Article Manager --&gt; Add New Article --&gt; Tab: Publishing<br> 2) make sure the calendar works ok.<br> 3) add into this file at this place: <a href="https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/html.php#L959">https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/html.php#L959</a></p> <p>$attribs = 'example';</p> <p>4) refresh the page<br> 5) make sure that the calendar is broken<br> 6) apply patch<br> 7) redo 3)<br> 8) refresh the page<br> 9) make sure that all works as bevor</p> <h3>Alternative way:</h3> <p>Code: &lt;?php echo JHtml::calendar(null, 'test', 'id-test', '%Y-%m-%d', 'class="blah" readonly="true"'); ?&gt;</p> <p>Insert this code into a view or index.php of your template (i.e. some php file that is viewable). Note the 3 php errors. Apply the PR. Errors go away.</p>
Labels Added: ? ?
avatar zero-24
zero-24 - comment - 10 May 2014

Thanks @elkuku and @roland-d the notices shoud fixed now.

avatar zero-24
zero-24 - comment - 10 May 2014

@wilsonge

Than we shoud do somthing that not allow using a string instend an array. e.g. with is_string and if this is true send a log message and remove/don't use it.

avatar wilsonge
wilsonge - comment - 10 May 2014

If php errors are being thrown when you're putting a string in that really should be enough of a hint you should be using the documented method :p

Like I don't think we need to log every change in the api since 1.5 - that would be crazy!!

avatar zero-24
zero-24 - comment - 10 May 2014

@wilsonge so i shoud remove the JLog thing?

avatar wilsonge
wilsonge - comment - 10 May 2014

Well I mean your thing is still expecting attribs to be an array for the readonly and disabled stuff and allowing a string you're never going to be able to work out if that's the case. An array should have been used since 1.6/1.7 (2011 anyhow) and so I think we just should force people to pass in an array

avatar roland-d
roland-d - comment - 10 May 2014

@wilsonge Is it not considered a B/C break if we now force an array?

As for the JLog entry, I think it should be removed, this will create a huge log for users and nothing they can do about it.

We need to decide if we can force the array or just leave it as is.

avatar wilsonge
wilsonge - comment - 10 May 2014

It would be for Joomla 1.6 when the change was made. Since then it's been labelled as an array and it should be called as such. Just because a string happened to work still doesn't mean that it's correct. https://github.com/joomla/joomla-cms/blob/df0b2d024a324ec426ce7f0c27f034505056d44a/libraries/joomla/html/html.php#L662 This is the line in 2010 (so pre J1.6) - where you can see it should only be an array or null.

avatar Bakual
Bakual - comment - 10 May 2014

If it currently works with a string, why change it and risk a broken extension?

As for the log: The deprecation logging will only be written if the user enabled that option in the debug plugin. By default it's turned off.

I would probably add the deprecation message in case someone passes a string and remove that possibility with 4.0.

avatar wilsonge
wilsonge - comment - 10 May 2014

Except it hasn't worked with a string for 8 months. If someone hasn't fixed their extension by now they have a problem :P Meh whatever works for you guys tho

avatar roland-d
roland-d - comment - 11 May 2014

I'd say leave it as it is now and force the array in Joomla! 4.0.

avatar Bakual
Bakual - comment - 11 May 2014

Except it hasn't worked with a string for 8 months.

I haven't tested it. Just reading the conversation :)
If it currently doesn't work, and isn't meant to work anyway. What are we trying to fix?

avatar wilsonge
wilsonge - comment - 11 May 2014

That's my point :P I don't see the need for this

avatar zero-24
zero-24 - comment - 11 May 2014

Except it hasn't worked with a string for 8 months.

hmm it has worked but only with a warning if you have error reporting on. (IIRC)

For me it is more a "issue" by the extentions developer. But i think we don't break anything if we handel it as proposed.

avatar roland-d
roland-d - comment - 12 May 2014

Actually I believe it does work, it only triggers some warnings, the style is still applied. So this change fixes those warnings.

It may not supposed to be working but since it does, we may as well get rid of those notices. Comes Joomla! 4, we can cast it to an array.

avatar elkuku
elkuku - comment - 12 May 2014

Or maybe we just accept arrays as well as strings, since now both of them are working without warnings/notices...
The Joomla! Way ™ •
Just fix the doc block :tongue:

avatar infograf768
infograf768 - comment - 28 May 2014

Please look at
#3654

and let's decide what we do as we have already the issue in core with smartsearch

avatar zero-24
zero-24 - comment - 28 May 2014

thanks @wilsonge it is fixed now

avatar phproberto
phproberto - comment - 11 Jun 2014

I don't see why we need to add a log message. If now it works with strings and arrays why? And if not are we going to add a log message for each function that is not used properly? I can understand that we avoid the warning and/or add the support for strings but why the log entry?

Also no being an array doesn't convert it into a string. If you still want to add a log entry you should change the message to only talk about the array requirement and avoid describing the type received just in case someone passes an object......

I would also suggest to cast (string) $attribs when using it and, as pointed by @elkuku, if the function is now going to support strings change the $attribs type to mixed in the doc block.

avatar zero-24
zero-24 - comment - 11 Jun 2014

@phproberto I have remove the JLog.

avatar Bakual Bakual - change - 29 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-29 13:52:39
avatar Bakual Bakual - close - 29 Jul 2014
avatar Bakual Bakual - close - 29 Jul 2014
avatar zero-24 zero-24 - head_ref_deleted - 8 Aug 2014
avatar Sophist-UK Sophist-UK - reference | 119693c - 7 Oct 14

Add a Comment

Login with GitHub to post a comment