65680[TASK] Fix phpstan checkFunctionArgumentTypes errors in ext:core DataHandling
Commit message
Review
-
Code review CR +2 Done
- Daniel Goerz +2
- Christian Kuhn +1
-
Verified V +2 Done
- Daniel Goerz +2
- Christian Kuhn +1
- TYPO3com +1 CI
- core-ci +1 CI
Issues 1
Files 7
- typo3/sysext/backend/Classes/Utility/BackendUtility.php+1 −1
- typo3/sysext/core/Classes/DataHandling/Localization/DataMapItem.php+1 −0
- typo3/sysext/core/Classes/DataHandling/Localization/DataMapProcessor.php+11 −11
- typo3/sysext/core/Classes/DataHandling/Localization/State.php+1 −1
- typo3/sysext/core/Classes/DataHandling/DataHandler.php22+63 −60
- typo3/sysext/core/Classes/DataHandling/ReferenceIndexUpdater.php+1 −1
- typo3/sysext/core/Classes/DataHandling/SlugHelper.php+4 −4
Review log 2942
Show 1317 earlier messages
-
Sascha Egerer uploaded patch set 1 09/09/20, 17:16
-
Sascha Egerer wrote 09/09/20, 17:27
Topic set to phpstan -
Sascha Egerer updated the commit message in patch set 2 09/09/20, 17:27
-
Daniel Goerz updated the commit message in patch set 3 09/10/20, 08:56
-
TYPO3com voted on patch set 3 V -1 09/10/20, 17:32 Completed build in 25m 17s on Thu, 10 Sep, 05:32 PM Test Summary: 73173 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5496
-
TYPO3com commented on patch set 3 09/10/20, 17:45 Completed build in 32m 46s on Thu, 10 Sep, 05:45 PM Test Summary: 73173 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5497
-
Alexander Schnitzler uploaded patch set 4 12/05/20, 12:13
-
Alexander Schnitzler commented on patch set 4 12/05/20, 12:14
Patchset 4 is just a rebase. -
Alexander Schnitzler uploaded patch set 5 12/05/20, 12:22
-
TYPO3com voted on patch set 4 V -1 12/05/20, 12:22 Completed build in 09m 00s on Sat, 5 Dec, 12:22 PM Test Summary: 32415 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7826
-
TYPO3com voted on patch set 5 V +1 12/05/20, 12:33 Completed build in 10m 40s on Sat, 5 Dec, 12:33 PM Test Summary: 32415 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7827
-
Oliver Klee voted on patch set 5 CR +1 12/05/20, 12:45
-
Alexander Schnitzler commented on patch set 5 12/19/20, 12:18
Unresolved
ping -
Sascha Egerer commented on patch set 5 CR -1 12/21/20, 10:28
DataHandler.php:1300$id can only be a non int if it's a "NEW" id (see line 1239). In this case this int cast does not make sense at all, right? So "$this->pageInfo()" should not be called if $id is not an int.DataHandler.php:3821`BackendUtility::getTSconfig_pidValue()` should be fixed instead. It does already have return type int so why do we need this typecast here?DataHandler.php:6050This would be a breaking change but i think is wrong anyways. Callback is, i think due to historic reasons, not a callable but an array of object + method name that is called by call_user_func_arrayDataHandler.php:6777I would use `$newRow = $this->checkStoredRecord($table, $id, $fieldArray, SystemLogDatabaseAction::UPDATE) ?? [];` insteadDataHandler.php:6865I would use `$newRow = $this->checkStoredRecord($table, $id, $fieldArray, SystemLogDatabaseAction::INSERT) ?? [];` insteadDataHandler.php:6894Why a hardcoded 0 instead of the $id? -
Alexander Schnitzler commented on patch set 5 12/21/20, 11:36
DataHandler.php:1300ReplyI agree. On the other hand, pageInfo is never called with `NEW` as the previous check on $status fails. And to be able to add method parameter type hints later, we need to make sure that all incoming data is prepared, hence the int cast, which is just a safety net.DataHandler.php:3821ReplyBecause the type hint is misleading. `getTSconfig_pidValue()` can return null as well. In that case we want to call `copyRecord()` with int 0, not null.DataHandler.php:6050ReplyTrue, would be breaking. But disagree on the "not a callable" statement. PHP accepts an array with object and method name as callable. See https://3v4l.org/I5RlZDataHandler.php:6777Reply UnresolvedAckDataHandler.php:6865Reply UnresolvedAckDataHandler.php:6894ReplyBecause $id is always "NEW" in this case and the log method does not accept NEW as record uid. It says > Record UID. Zero if NA Hence the hard coded 0 here. We can also adjust the phpdoc of method log() and allow strings. Or we put the logging up into the previous condition before the return and have the actual value of the created record. That would make most sense I guess. -
Sascha Egerer commented on patch set 5 12/23/20, 09:45
DataHandler.php:1300ReplyI agree and disagree. Stuff like that can introduce some really weird bugs. Even if the method is not yet called with a string it may be called at some time. So i would better go with an exception here so we are really sure its never a string. Something like ``` if(!MathUtility::canBeInterpretedAsInteger($id)) { throw \InvalidArgumentException(...); } ``` Then we are sure that this cast does never cast an unexpected value.DataHandler.php:3821ReplyOk but then we should adjust the return type of getTSconfig_pidValue as well. And i would also go with `$tscPID ?? 0` instead as it's more specificDataHandler.php:6050ReplyAh ok. Didn't know that. It does really accept an array as callable type. https://3v4l.org/FDIT1DataHandler.php:6894Reply> Or we put the logging up into the previous condition before the return and have the actual value of the created record. That would make most sense I guess. I don't think this will work as then we will always have a log message. For me the change is ok like it is. -
Alexander Schnitzler uploaded patch set 6 12/23/20, 12:34
-
TYPO3com voted on patch set 6 V -1 12/23/20, 12:43 Completed build in 09m 23s on Wed, 23 Dec, 12:43 PM Test Summary: 69 of 32781 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8456
-
Alexander Schnitzler uploaded patch set 7 12/23/20, 13:00
-
Oliver Klee voted on patch set 7 CR +1 12/23/20, 13:05
-
TYPO3com voted on patch set 7 V -1 12/23/20, 13:11 Completed build in 10m 33s on Wed, 23 Dec, 01:11 PM Test Summary: 31 of 32781 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8457
-
Alexander Schnitzler uploaded patch set 8 12/23/20, 14:13
-
Alexander Schnitzler commented on patch set 8 12/23/20, 14:19
DataHandler.php:1300Reply UnresolvedTried different things and casting to int is the only possible way here without ripping the if statement apart. $id only needs to be an int if it's used as param for pageInfo(). We can of course make the current oneline more complex: > if ($table === 'pages' && ($this->admin || $status === 'new' || $this->pageInfo($id, 'perms_userid') == $this->userid)) { > if ($table === 'pages' && ($this->admin || $status === 'new' || (is_int($id) && $this->pageInfo($id, 'perms_userid') == $this->userid))) { I think it's not worth it.DataHandler.php:1300This doesn't work as we deal with string id's here as well.DataHandler.php:3821ReplyAgreed. -
TYPO3com voted on patch set 8 V +1 12/23/20, 14:23 Completed build in 10m 22s on Wed, 23 Dec, 02:23 PM Test Summary: 32540 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8458
-
Oliver Klee voted on patch set 8 CR +1 12/23/20, 14:44
-
Christian Kuhn uploaded patch set 9 03/04/21, 10:45
-
TYPO3com voted on patch set 9 V +1 03/04/21, 10:52 Completed build in 07m 03s on Thu, 4 Mar, 10:52 AM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9841
-
core-ci voted on patch set 9 V +1 03/04/21, 10:55 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1171
-
Daniel Goerz commented on patch set 9 03/04/21, 10:56
Quick update: We (Lolli and me) discussed the next steps in terms of this phpstan rule and decided for now to not backport this patch to v10. We will see if we enable the rule in v10 to have a more strict static code analysis on backports or if we enable the rule for v11 only. -
Christian Kuhn voted on patch set 9 V +1 CR +1 03/04/21, 11:25
-
Daniel Goerz commented on patch set 9 V -1 03/04/21, 13:35
Still 30 errors in core/Classes/DataHandling -
Daniel Goerz commented on patch set 9 03/04/21, 14:04
DataHandler.php:1499I do not get this change. With this we now have to cast $id to integer on every call this method performs with $id as a prameter.DataHandler.php:1803UnresolvedI do not get this change. With this we now have to cast $id to integer on every call this method performs with $id as a prameter. -
Christian Kuhn commented on patch set 9 V 0 CR 0 03/04/21, 17:23
DataHandler.php:1499Reply Unresolvedlet's revert this for now. -
Daniel Goerz uploaded patch set 10 03/04/21, 18:04
-
Daniel Goerz uploaded patch set 11 03/04/21, 18:09
-
TYPO3com voted on patch set 10 V +1 03/04/21, 18:12 Completed build in 07m 51s on Thu, 4 Mar, 06:12 PM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9846
-
core-ci voted on patch set 10 V +1 03/04/21, 18:15 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1176
-
TYPO3com voted on patch set 11 V +1 03/04/21, 18:15 Completed build in 06m 34s on Thu, 4 Mar, 06:15 PM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9847
-
core-ci voted on patch set 11 V +1 03/04/21, 18:21 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1177
-
Christian Kuhn voted on patch set 11 V +1 CR +1 03/04/21, 18:29
-
Daniel Goerz voted on patch set 11 V +2 CR +2 03/04/21, 18:45
-
Daniel Goerz merged patch set 12 03/04/21, 18:45