50197[BUGFIX] Use reflection information in getGettablePropertyNames
Commit message
Review
-
Code review CR +2
- Philipp Gampe +2
- Markus Klein +1
-
Verified V +2
- Philipp Gampe +2
- Markus Klein +1
- TYPO3com +1 CI
Issues 1
Files 3
Review log 3339
Show 1114 earlier messages
-
Nicole Hummel uploaded patch set 1 10/12/16, 16:00
-
TYPO3com voted on patch set 1 V -1 10/12/16, 16:04 Completed build in 04m 45s on Wed, 12 Oct, 06:04 PM Test Summary: 34 of 19554 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3677
-
Nicole Hummel uploaded patch set 2 10/12/16, 17:46
-
TYPO3com voted on patch set 2 V -1 10/12/16, 17:52 Completed build in 05m 08s on Wed, 12 Oct, 07:52 PM Test Summary: 19554 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3678
-
Nicole Hummel uploaded patch set 3 10/12/16, 18:12
-
TYPO3com voted on patch set 3 V +1 10/12/16, 18:17 Completed build in 04m 59s on Wed, 12 Oct, 08:17 PM Test Summary: 19554 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3679
-
Claus Due commented on patch set 3 10/17/16, 21:52
Is there another way we could solve this? It undoes a significant portion of the optimisation I did in ObjectAccess a while ago (which specifically avoids reflection in standard cases). Off the top of my head, this method looks even slower than the original method of get_class_vars. Side note: it should be any function that has zero required arguments, not any function that has zero arguments at all. Technically, that is a getter with a default behavior ;) -
Claus Due commented on patch set 3 10/17/16, 21:57
Side note: Fluid standalone has this same issue if you try to access a getter method of this type. On CMS it will use the ObjectAccess which with this patch would return NULL, on standalone Fluid it would fail with the php warning. However: Fluid itself does not have a "get all gettable properties" function, so this would indeed be a problem in the case you describe. Maybe our strategy should be to target the "get all gettable properties" function so it skips ones it can't get? -
Claus Due commented on patch set 3 10/18/16, 00:09
Nevermind the first comment, I came back and checked it properly this time and you are correctly targeting methods that are only called when it truly is required to reflect all properties. It doesn't directly affect the performance cleanup I did. So I have only two points about this: * I think we should include all getter methods which have no required arguments, e.g. if the method only has optional arguments we can still call it. * There is also getSettablePropertyNames but it appears to have zero usages in all of TYPO3 so the question is... should it also be changed to follow the same logic (and fail if setter has more than one required argument), or should that method be removed (it's public and static so I guess API). Sorry about the confusion. Going on hour 14 now so I "missed a spot". -
Philipp Gampe voted on patch set 3 CR +1 12/31/16, 13:44
-
Markus Klein commented on patch set 3 CR +1 01/03/17, 10:46
nice fix! -
Markus Klein commented on patch set 3 01/03/17, 10:51
One questionObjectAccess.php:229Why do we need a ReflectionObject here? Shouldn't ReflectionClass suffice? -
Nicole Hummel commented on patch set 3 01/04/17, 14:18
ObjectAccess.php:229ReplyNo, ReflectionClass can't handle stdClass properties. This is the reason for the difference here. There is an unit test for this already which fails when using ReflectionClass only. -
Markus Klein commented on patch set 3 01/04/17, 14:31
ObjectAccess.php:229ReplyI still do not get why this is the case, since ReflectionObject is extending ReflectionClass and both except an object as constructor value. I didn't find any documentation about this, so is this a PHP bug?
-
Nicole Hummel commented on patch set 3 01/04/17, 14:49
ObjectAccess.php:229ReplyMy guess: ReflectionClass can handle objects because if its class names and the reflection of the class itself. StdClass doesn't define any properties nor methods. So the real object has to be analyzed. -
Markus Klein commented on patch set 3 V +1 01/04/17, 15:04
ObjectAccess.php:229ReplyOkay, that makes much more sense this way. Thanks. -
Claus Due commented on patch set 3 01/04/17, 15:13
ObjectAccess.php:229ReplyAccording to the PHP source, ReflectionObject has one difference compared to ReflectionClass, and that is the ability to export a var_export-like representation of any object (including stdClass). Whereas ReflectionClass operates on the class name (no surprise!) which if it is stdClass prevents correctly reading *which* properties are actually available, since any property on an stdClass is dynamic and so cannot be reflected based on the class name "stdClass". Hope that explains it. That being said: ReflectionObject should be capable of covering both use cases. EDIT: it can cover both, because this method always receives an object instance, never a class name. -
Nicole Hummel commented on patch set 3 01/04/17, 15:20
ObjectAccess.php:229ReplyI thought using ReflectionClass is a bit more sufficient in speed and memory. Should we always use ReflectionObject instead? -
Claus Due commented on patch set 3 01/04/17, 15:39
Most of the features of those two PHP classes do appear to be shared, so unless we can document a significant difference, I'd go with just ReflectionObject. If I understand the PHP source correctly, ReflectionObject should perform identical to ReflectionClass *unless* the scanned object instance was assigned dynamic public properties. One might even argue that always using ReflectionObject also solves that "bug", dynamic properties not being returned for not-stdClass instances ;) -
Nicole Hummel uploaded patch set 4 01/04/17, 16:11
-
Nicole Hummel commented on patch set 4 01/04/17, 16:13
ObjectAccess.php:232We cannot use ReflectionObject here as the test case defines dynamic properties of an object and expects them to be excluded from this function. I decided to early return for stdClass and use ReflectionClass for all other objects. -
TYPO3com voted on patch set 4 V +1 01/04/17, 16:15 Completed build in 04m 13s on Wed, 4 Jan, 05:15 PM Test Summary: 54913 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-6217
-
Nicole Hummel uploaded patch set 5 01/04/17, 16:20
-
Nicole Hummel commented on patch set 5 CR -1 01/04/17, 16:24
Working on it -
TYPO3com voted on patch set 5 V -1 01/04/17, 16:25 Completed build in 04m 18s on Wed, 4 Jan, 05:25 PM Test Summary: 90 of 54913 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-6218
-
Nicole Hummel uploaded patch set 6 01/04/17, 16:36
-
TYPO3com voted on patch set 6 V +1 01/04/17, 16:41 Completed build in 04m 52s on Wed, 4 Jan, 05:41 PM Test Summary: 54913 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-6219
-
Claus Due commented on patch set 6 01/04/17, 18:08
ObjectAccess.php:232ReplyWe might have to address that in another patch then, since getProperty allows public dynamic properties on non-stdClass to be returned this would appear to be an inconsistent behavior. But I'm fine with the current state (and any patch we make to unify behavior could simply remove the early return, good choice!). -
Nicole Hummel commented on patch set 6 01/04/17, 18:57
@Claus: According to the tests this is not the intended way. Unit tests fail if the dynamic property is returned. -
Claus Due commented on patch set 6 01/04/17, 19:01
> Unit tests fail if the dynamic property is returned. I know, that's why I mentioned that this is inconsistent with getProperty (and therefore getPropertyPath) which will read such public properties. The logical assumption being that getAllGettablePropertyNames should return names of *all* properties which the other two methods can read. Currently, it does not - it even explicitly tests that it does not, as you found out. -
Philipp Gampe voted on patch set 6 CR +1 01/05/17, 00:08
-
Markus Klein commented on patch set 6 01/13/17, 10:14
Claus, Nicole: What's the status here? -
Claus Due commented on patch set 6 01/13/17, 10:22
No objection from me to merge this - but imho we do need to address the inconsistency between this method and getProperty concerning dynamic properties on userland classes. This can be done in a different merge request which then also changes the unit test expectations. -
Markus Klein voted on patch set 6 CR +1 01/13/17, 10:25
-
Markus Klein voted on patch set 6 V +1 01/13/17, 10:27
-
Nicole Hummel commented on patch set 6 01/13/17, 10:53
IMHO you can change the expectation only in master, not in the backport. So for me this would definitely be an own patch -
Philipp Gampe voted on patch set 6 CR +2 V +2 01/19/17, 12:30
-
Gerrit merged patch set 6 01/19/17, 12:30
-
Claus Due commented on patch set 7 01/19/17, 16:54
Just wanted to ask if anyone is planning to work on the inconsistency between getGettablePropertyNames and getProperty(Path)? If not, I may take care of this if I get bored ;)