67174[BUGFIX] Avoid PHP warning in Extbase Session->hasIdentifier
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 1
Review log 67
-
Claus Due uploaded patch set 1 12/17/20, 10:44
-
TYPO3com voted on patch set 1 V +1 12/17/20, 10:53 Completed build in 08m 57s on Thu, 17 Dec, 10:53 AM Test Summary: 32433 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8225
-
Oliver Klee voted on patch set 1 CR +1 12/17/20, 18:17
-
Oli Bartsch commented on patch set 1 CR -1 12/17/20, 20:06
Hi, I unfortunately can't comprehend this patch. `null[$identifier]` will not lead to this warning. See: https://3v4l.org/uBBVr. Illegal offset type is triggered when you try to use an array or object as array key. But as far as I see, this is not the case here. `$this->identifierMap` is initialized as an empty array. `getClassIdentifier()` will always return a string, since it's type hinted and would therefore lead to type errors otherwise. See this more detailed example: https://3v4l.org/C4o24. The only possibility I see is that an array or object is provided as `$identifier` (Since this parameter is not type-hinted, this would be possible). This however then would be an error on the calling code. However, the question for me is: How can I reproduce this? Sharing the full stake trace would help a lot. -
Claus Due commented on patch set 1 12/18/20, 11:48
Reply
You are completely right... the fix was actually a false positive that prevented a different issue. Some code in my customer's project was doing Repository->findByUid($object) which meant the $identifier in this code was an object. The warning was only prevented with this merge request, by the coincidence that no instances of $className had been previously loaded - the same problem would happen even with this fix, if that had been the case. I would have noticed this if I had been able to use xdebug but unfortunately the error only happened in production. So I'll close this merge request but leave the issue open. Making the arguments for Session->hasIdentifier() strict would prevent it (and dispatch a much more specific error), as would throwing an exception - but neither of those are appropriate to merge to 9.5 and 10.4 I think. Sorry for wasting time :/ -
Claus Due abandoned the change 12/18/20, 11:49
Problem reported in issue is only coincidentally fixed by this change - the true fix has to be either strict argument types for Session->hasIdentifier, or throwing an exception if $identifier is not scalar. -
Oli Bartsch commented on patch set 1 12/18/20, 12:54
Reply Unresolved
No problem :) I'm glad we could figure this out.