? ? Success

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
4 Sep 2017

Summary of Changes

It seems that property_exists has different behavior at PHP HHVM, when work with XML object.
This make Joomla! fail in a lot of places where JFormField::getAttribute() in use.

Testing Instructions

You need PHP HHVM installed.

Then run next code:

JFormHelper::loadFieldClass('text');
$field = new JFormFieldText();
$field->setup(new SimpleXMLElement('<field type="text" label="Text" drink="beer"/>'), '');

var_dump($field->getAttribute('drink'));
var_dump($field->getAttribute('food'));

Expected result

"beer"
null

Actual result

null
null

Documentation Changes Required

none

avatar joomla-cms-bot joomla-cms-bot - change - 4 Sep 2017
Category Libraries
avatar Fedik Fedik - open - 4 Sep 2017
avatar Fedik Fedik - change - 4 Sep 2017
Status New Pending
avatar Fedik Fedik - change - 4 Sep 2017
The description was changed
avatar Fedik Fedik - edited - 4 Sep 2017
avatar csthomas csthomas - test_item - 4 Sep 2017 - Tested successfully
avatar csthomas
csthomas - comment - 4 Sep 2017

I have tested this item successfully on 203424c

Test is OK, I tested on local php 7.0 and and other versions at http://sandbox.onlinephpfunctions.com/ and https://3v4l.org/ with code:

<?php
        //Enter your code here, enjoy!
error_reporting(E_ALL);
$a = new SimpleXMLElement('<field type="text" label="Text" drink="beer"/>');

var_dump($a->attributes()->drink);
echo "\n";
echo $a->attributes()->drink;
echo "\n";
var_dump($a->attributes()->not_exists);
echo "\n";
echo $x; // Should throw PHP Notice
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/17861">issues.joomla.org/tracker/joomla-cms/17861</a>.</sub>
avatar bembelimen
bembelimen - comment - 11 Sep 2017

Are you sure, that ->name always exists? perhaps: isset(...)

avatar Fedik
Fedik - comment - 11 Sep 2017

@bembelimen it is XML object there can exist any ? even $attr->somethingRandom,
but I need to update it to check for null

avatar Fedik Fedik - change - 11 Sep 2017
Labels Added: ?
avatar Fedik
Fedik - comment - 11 Sep 2017

ok, I have made update to make sure attribute exists

avatar csthomas csthomas - test_item - 28 Oct 2017 - Tested successfully
avatar csthomas
csthomas - comment - 28 Oct 2017

I have tested this item successfully on 70440df


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

avatar photodude
photodude - comment - 3 Dec 2017

I ran the existing unit tests on HHVM 3.18.5 to test for this issue, nothing came up.
Looks like we should implement a new unit test to validate the issue and the fix.

avatar photodude
photodude - comment - 9 Jan 2018

Looking at the code again, this is a good standard code simplification.
Should move forward with this PR, no additional unit tests should be needed.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Jan 2018

@photodude can you please mark your Test as successfully (if you comment means this)?

avatar photodude
photodude - comment - 10 Jan 2018

@franz-wohlkoenig Tested just by code review.
With a structural change like this we probably should have an actual test on a site to verify that JFormField::getAttribute() is working as expected (although I have no expectation of any issues from this change).

avatar csthomas
csthomas - comment - 10 Jan 2018

@photodude You can test it in your own php and check if everything is OK. I will be enough.

avatar photodude photodude - test_item - 10 Jan 2018 - Tested successfully
avatar photodude
photodude - comment - 10 Jan 2018

I have tested this item successfully on 70440df

Installed patch via the patch tester and checked random forms on J3.8.3 in php 5.6
No problems, everything works as expected.


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

avatar Quy Quy - change - 10 Jan 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 10 Jan 2018

RTC


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

avatar mbabker mbabker - change - 16 Jan 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-01-16 22:50:34
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 16 Jan 2018
avatar mbabker mbabker - merge - 16 Jan 2018
avatar photodude
photodude - comment - 16 Feb 2018

@Fedik no need for future HHVM related PR's They are only going to support Hack lang from now on
https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html

Add a Comment

Login with GitHub to post a comment