60343[WIP][FEATURE] Introduce PSR-14 based EventDispatcher as hook replacement
Commit message
Review
-
Code review CR 0
-
Verified V 0
Files 56
- typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaFlexPrepareTest.php+4 −0
- typo3/sysext/core/Classes/Authentication/Event/AfterBackendGroupResolvingEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Authentication/Event/AfterLoginEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Authentication/Event/AfterLogoutEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Authentication/Event/AfterUserLookUpEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Authentication/Event/BeforeLogoutEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Authentication/Event/CalculatePagePermissionsEvent.phpnew+59 −0
- typo3/sysext/core/Classes/Authentication/Event/CheckRecordAccessEvent.phpnew+81 −0
- typo3/sysext/core/Classes/Authentication/Event/FailedLoginEvent.phpnew+42 −0
- typo3/sysext/core/Classes/Authentication/Event/ModifyBackendGroupConstraintsQueryEvent.phpnew+85 −0
- typo3/sysext/core/Classes/Authentication/Event/ModifyDefaultUploadFolderEvent.phpnew+86 −0
- typo3/sysext/core/Classes/Authentication/Event/ModifyPagePermissionsEvent.phpnew+57 −0
- typo3/sysext/core/Classes/Authentication/Event/UserAuthenticationEvent.phpnew+40 −0
- typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php4+19 −30
- typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php9+33 −62
- typo3/sysext/core/Classes/Cache/Frontend/Event/BeforeFlushByTagEvent.phpnew+56 −0
- typo3/sysext/core/Classes/Cache/Frontend/Event/BeforeSetCacheEntryEvent.phpnew+110 −0
- typo3/sysext/core/Classes/Cache/Frontend/AbstractFrontend.php+5 −5
- typo3/sysext/core/Classes/Cache/Frontend/VariableFrontend.php+8 −9
- typo3/sysext/core/Classes/Compatibility/HookListeners.php2new+480 −0
Show 36 more files
- typo3/sysext/core/Classes/Configuration/Event/AfterExtensionTablesLoadedEvent.phpnew+24 −0
- typo3/sysext/core/Classes/Configuration/FlexForm/Event/AfterFetchDataStructureEvent.phpnew+56 −0
- typo3/sysext/core/Classes/Configuration/FlexForm/Event/AfterFlexParsingEvent.phpnew+92 −0
- typo3/sysext/core/Classes/Configuration/FlexForm/Event/BeforeFetchDataStructureEvent.phpnew+72 −0
- typo3/sysext/core/Classes/Configuration/FlexForm/Event/BeforeFlexParsingEvent.phpnew+104 −0
- typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php+26 −66
- typo3/sysext/core/Classes/Controller/FileDumpController.php+8 −11
- typo3/sysext/core/Classes/Database/TableConfigurationPostProcessingHookInterface.php+2 −0
- typo3/sysext/core/Classes/Html/Event/ProcessRteHtmlParserContentForDatabaseEvent.phpnew+82 −0
- typo3/sysext/core/Classes/Html/Event/ProcessRteHtmlParserContentForEditorEvent.phpnew+82 −0
- typo3/sysext/core/Classes/Html/RteHtmlParser.php2+8 −9
- typo3/sysext/core/Classes/Imaging/Event/OverrideIconOverlayEvent.phpnew+76 −0
- typo3/sysext/core/Classes/LinkHandling/Event/ResolveLinkDetailsFromCustomUriEvent.phpnew+53 −0
- typo3/sysext/core/Classes/LinkHandling/LinkService.php+5 −8
- typo3/sysext/core/Classes/Type/File/Event/AfterMimeTypeGuessingForFileEvent.phpnew+66 −0
- typo3/sysext/core/Classes/Type/File/FileInfo.php+5 −13
- typo3/sysext/core/Classes/TypoScript/Event/AfterRunThroughTypoScriptTemplatesEvent.phpnew+121 −0
- typo3/sysext/core/Classes/TypoScript/Event/AfterStaticTypoScriptSourcesInclusionEvent.phpnew+109 −0
- typo3/sysext/core/Classes/TypoScript/Event/BeforeStaticTypoScriptSourcesInclusionEvent.phpnew+109 −0
- typo3/sysext/core/Classes/TypoScript/Event/TypoScriptParseValueModifierEvent.phpnew+82 −0
- typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php1+6 −5
- typo3/sysext/core/Classes/TypoScript/TemplateService.php+29 −29
- typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php+6 −8
- typo3/sysext/core/Classes/Utility/File/ExtendedFileUtilityProcessDataHookInterface.php+2 −0
- typo3/sysext/core/Configuration/EventListeners.phpnew+176 −0
- typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php+11 −0
- typo3/sysext/core/Tests/Unit/Cache/Frontend/AbstractFrontendTest.php+13 −0
- typo3/sysext/core/Tests/Unit/Cache/Frontend/VariableFrontendTest.php+17 −0
- typo3/sysext/core/Tests/Unit/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcherTest.php+2 −0
- typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php+3 −0
- typo3/sysext/core/Tests/Unit/LinkHandling/LinkServiceTest.php+13 −0
- typo3/sysext/core/Tests/Unit/Type/File/FileInfoTest.php+13 −0
- typo3/sysext/core/Tests/Unit/Type/File/ImageInfoTest.php+11 −0
- typo3/sysext/core/Tests/Unit/TypoScript/TemplateServiceTest.php+7 −0
- typo3/sysext/form/Tests/Unit/Controller/FormFrontendControllerTest.php+4 −0
- typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php+9 −0
Review log 2950
Show 1625 earlier messages
-
Benni Mack uploaded patch set 1 03/26/19, 16:01
-
TYPO3com voted on patch set 1 V -1 03/26/19, 16:04 Completed build in 02m 22s on Tue, 26 Mar, 05:04 PM Test Summary: 3450 of 39251 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-32976
-
Mathias Brodala commented on patch set 1 03/27/19, 08:42
This must be EventListeners according to the code which makes more sense, too. -
Markus Poerschke commented on patch set 1 03/30/19, 21:40
This looks very promising to me! :) I left some ideas and concerns I saw. Hopefully this is ok with you. :)I would change this line to: "a flexible registration mechanism to register listeners"Unresolved
Actually a dispatcher can also be used in the domain / business logic. Actually the text could also be "copied" from here: https://www.php-fig.org/psr/psr-14/#definitionsChange "it’s" to "its"."to be 100% compliant to the PSR-14 recommendation"AbstractUserAuthentication.php:822I understand why the "foreach" was moved to the event listeners, but by doing that you have to pass the emitter to the event. That means that each listener must depend on the interface of the emitter. The aim should be that the listeners only depend on the event that is passed. If we have a look at the recommendation: «Events are objects that act as the unit of communication between an Emitter and appropriate Listeners.» Now we are talking to the emitter directly. So the event class cannot serve the purpose of beeing the unit of communication between emitter and listeners. «It is RECOMMENDED, but NOT REQUIRED, that Event objects support lossless serialization and deserialization;» Mostly emitters will not be able to be serialized, because of their complex dependencies (e.g. database connection etc.). Furthermore the event should be „any arbitrary PHP object“. I suggest to move back the foreach and add a deprecation warning if the array is not empty. Disatvantage: the order cannot be set correctly anymore. Either the legacy hooks are executed first or the new events. But anyhow the hooks are executed in a block so that should not be a big problem.AbstractUserAuthentication.php:822UnresolvedI think the emitter of an event should not be added to the event as an attribute. I guess that in a long term it makes sense to make the properties of this class protected? So adding the relevant values as separate properties of the event.BackendUserAuthentication.php:547When I first saw this lines, I was asking myself what "evt" is standing for. I think renaming the variable to "event" is appropiate.BackendUserAuthentication.php:1393I like the idea that you can pass the query builder to add custom constraints etc.BackendUserAuthentication.php:1395If the QueryBuilder is passed to the event, the constraints can be added to the query builder directly. There is no need to add the constrains to the event first and then to add them to the query builder.BackendUserAuthentication.php:1876If the emitter is the first argument of the constructor it will be very hard to remove it again later.HookListeners.php:343UnresolvedMissing class import.PackageListenerProvider.php:70Why do you use "json_encode" here? Shouldn’t the cache take care of propper serialization?PackageListenerProvider.php:89The listeners are called in a wrong order. When I add a listener for an interface but specify that it should be called before a listener that is registered for a concrete class it will be still executed after it. Therefore the listeners may not be grouped by the "event class" in the property "listeners". They must be placed in flat array instead. $listeners = [ [ 'target' => 'The\ListenerClass::method', 'eventClass' => 'The\Event\ClassName' ], ]; $eventClasses = [get_class($event)]; array_push($eventClasses, class_parents($event), class_implements($event)); foreach ($listeners as $listener) { if (in_array($listener['eventClass'], $eventClasses)) { yield $this->getCallableFromTarget($listener['target']); } }PackageListenerProvider.php:147If a string syntax like this is callable why not using the old TypoScript syntax "->"? How can a static method beeing called?locallang.xlf:40How about dropping the word "Hooks" and add "(PSR-14)" instead. This is how it was done for the HTTP Middlewares. -
Mathias Brodala commented on patch set 1 04/01/19, 07:15
PackageListenerProvider.php:148Wouldn't it be easier to move this top the top? The goal of this method is to return a callable after all ...PackageListenerProvider.php:152This sounds confusing. Better: Target "%s" is not callable -
Benni Mack commented on patch set 1 04/08/19, 22:58
Reply Unresolved
yup.Reply Unresolved
AckReply Unresolved
yup.Reply Unresolved
> "to be 100% compliant to the PSR-14 recommendation" Yeah, makes senseAbstractUserAuthentication.php:822ReplyYeah, keeping the hooks here in place instead of creating "Legacy Listeners" is another way of handling it. Felt easier for me when starting to migrate that I'm sure I covered all hooks properly. I'm also considering activating the hooks only via a feature flag to improve perf. as a "strict event listeners" mode. However I don't really care on how to phase the hooks out as long as we're sure we have everything covered and have a clean code base at some point. As for serialization, this part was added to the spec due to the fact that people can use async / deferred calls to the events. At this point, TYPO3 does not support real and proper serialization so it is recommended but we don't do that by default yet. `Furthermore the event should be „any arbitrary PHP object“.` What do you mean with this?BackendUserAuthentication.php:547Replyno probs, that was taken from JS (where people also use $e for "Event"). I've seen other implementations that call e.g. "return $dispatcher->dispatch(...)->getQueryConstraint();" directly.BackendUserAuthentication.php:1395Replyquestion is who is responsible for doing this "logic" - adding the constraints to the queryBuilder - then? The constraints from the top of this method should be added, but not overridden then, right?BackendUserAuthentication.php:1876Reply Unresolvedtrue.PackageListenerProvider.php:70Replyunserialize() could lead to security issues and unneeded side-effects. At this point we use json_* functions so it is very clear that the data that we use in this ListenerProvider needs a strict PHP array without any magic callables or anonynmous classes.PackageListenerProvider.php:89Reply Unresolvednice one. thanks! I will def. add tests for that.PackageListenerProvider.php:147Replysyntax is the same as for backend routes and all array-registered syntax we're using since TYPO3 v7. the "::" is actually closer to other systems (e.g. Symfony) where-as `->` is TYPO3 specific.PackageListenerProvider.php:148ReplyHey, I have to check this again - I had this in TYPO3 v7 when we added this logic for Backend Routing Dispatching. AFAIK if we'd do this then Line 141-145 would not be executed without using GeneralUtility::makeInstance().PackageListenerProvider.php:152Reply UnresolvedACKlocallang.xlf:40Replyno prob. -
Benni Mack uploaded patch set 2 04/12/19, 18:17
-
TYPO3com voted on patch set 2 V -1 04/12/19, 18:24 Completed build in 04m 38s on Fri, 12 Apr, 08:24 PM Test Summary: 4876 of 39263 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33221
-
Markus Poerschke commented on patch set 2 04/12/19, 20:31
AbstractUserAuthentication.php:822ReplyIn my understanding the part "arbitrary PHP object" (quoted from the specification) plays together with the possibility of serialization. Also I unterstand it that the emitter should not be passed. But: in this case it might be nessecary to do so. Comparing to events in JavaScript/HTML, the "target" is also passed to the event. I would leave it as it is in this change. Regarding the serialization: actually that would make everything even more complex. If some one needs asynchronous work, they can copy the event and persistent it in their own data format.PackageListenerProvider.php:70ReplySounds reasonable to me.PackageListenerProvider.php:147ReplyKeep the stuff uniform makes sense!PackageListenerProvider.php:148ReplyAck. -
Markus Poerschke commented on patch set 2 04/12/19, 20:33
BackendUserAuthentication.php:547ReplyDonelocallang.xlf:40ReplyDone -
Benni Mack uploaded patch set 3 04/14/19, 09:18
-
TYPO3com voted on patch set 3 V -1 04/14/19, 09:21 Completed build in 02m 30s on Sun, 14 Apr, 11:21 AM Test Summary: 4124 of 39263 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33245
-
Markus Poerschke commented on patch set 3 04/14/19, 15:56
I just had another look. Looks good so far. I found two classes where, I would not use the event listener.BackendUserAuthentication.php:1395Reply UnresolvedIt could be handled like the QueryRestrictionInterface: there only the expression builder is passed to the method that will then return a CompositeExpression.HookListeners.php:83UnresolvedAccodring to the standard the listeners should return void. The return value is currently not used. „A Listener SHOULD have a void return, and SHOULD type hint that return explicitly. A Dispatcher MUST ignore return values from Listeners.“ The correct method signautre should be: public function onAbstractUserAuthenticationPostUserLookUp(AfterUserLookUpEvent $event): voidRteHtmlParser.php:213UnresolvedI think this is not a use case for event listeners. I would not transform this to use event listeners, because only one single class per "$cmd" should be called. Especially the logic "if ($evt->isPropagationStopped()) {" looks confusing to me. Why aren’t the other commands implemented as listeners? If they would be implemented as listerners too, then "$value = $event->getValue()" could be called in any cases and no special condition is needed. My suggestion: do not use event dispatcher here and keep the old implementation. --- Idea how to solve this issue (not scope of this change): I think in the future each case of the "switch($cmd)" might be moved to a dedicated class. There will be a class you can register objects of type "TransformerInterface" for each "$cmd". Maybe a it could be implemented like this: $transformersRegistry = GeneralUtility::makeInstance(TransformersRegistry::class); if ($transformersRegistry->hasTransformer($cmd)) { $value = $transformersRegistry->getTransformer($cmd)->transform($value); } The concrete transformers could be registered using tags within the dependency container (PSR-11).RteHtmlParser.php:241UnresolvedSame as above. Do not use event listener and keep original implementation.TypoScriptParser.php:601UnresolvedSee comment in RteHtmlParser.php. Leave the old implementation for now. -
Benni Mack uploaded patch set 4 05/07/19, 09:50
-
Benni Mack uploaded patch set 5 05/07/19, 09:55
-
TYPO3com voted on patch set 4 V -1 05/07/19, 10:40 Completed build in 42m 59s on Tue, 7 May, 12:40 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33767
-
TYPO3com voted on patch set 5 V -1 05/07/19, 10:54 Completed build in 14m 13s on Tue, 7 May, 12:54 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33768
-
Benni Mack uploaded patch set 6 05/20/19, 20:11
-
TYPO3com voted on patch set 6 V -1 05/20/19, 20:13 Completed build in 02m 37s on Mon, 20 May, 10:13 PM Test Summary: 3801 of 39295 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33951
-
Benni Mack uploaded patch set 7 05/24/19, 20:42
-
TYPO3com voted on patch set 7 V -1 05/24/19, 20:45 Completed build in 02m 23s on Fri, 24 May, 10:45 PM Test Summary: 5509 of 39332 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34034
-
Benni Mack uploaded patch set 8 05/25/19, 21:29
-
TYPO3com voted on patch set 8 V -1 05/25/19, 21:32 Completed build in 02m 36s on Sat, 25 May, 11:32 PM Test Summary: 7903 of 39332 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34044
-
Benni Mack uploaded patch set 9 05/25/19, 22:02
-
TYPO3com voted on patch set 9 V -1 05/25/19, 22:05 Completed build in 02m 36s on Sun, 26 May, 12:05 AM Test Summary: 4465 of 39332 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34045
-
Benni Mack uploaded patch set 10 05/25/19, 22:28
-
TYPO3com voted on patch set 10 V -1 05/25/19, 22:31 Completed build in 02m 44s on Sun, 26 May, 12:31 AM Test Summary: 9786 of 46732 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34046
-
Benni Mack uploaded patch set 11 05/27/19, 15:24
-
TYPO3com voted on patch set 11 V -1 05/27/19, 15:34 Completed build in 09m 08s on Mon, 27 May, 05:34 PM Test Summary: 3353 of 46809 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34068
-
Benni Mack uploaded patch set 12 05/29/19, 19:13
-
TYPO3com voted on patch set 12 V -1 05/29/19, 19:24 Completed build in 10m 28s on Wed, 29 May, 09:24 PM Test Summary: 2708 of 46809 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34090
-
Benni Mack uploaded patch set 13 05/29/19, 20:19
-
TYPO3com voted on patch set 13 V -1 05/29/19, 20:31 Completed build in 11m 39s on Wed, 29 May, 10:31 PM Test Summary: 2824 of 46809 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34094
-
Benni Mack uploaded patch set 14 07/13/19, 13:30
-
TYPO3com voted on patch set 14 V -1 07/13/19, 13:42 Completed build in 11m 32s on Sat, 13 Jul, 03:42 PM Test Summary: 2981 of 47361 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34994
-
Benni Mack uploaded patch set 15 07/13/19, 14:20
-
TYPO3com voted on patch set 15 V -1 07/13/19, 14:31 Completed build in 10m 55s on Sat, 13 Jul, 04:31 PM Test Summary: 2691 of 47361 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34997
-
Benni Mack uploaded patch set 16 07/25/19, 09:13
-
TYPO3com voted on patch set 16 V -1 07/25/19, 09:19 Completed build in 05m 35s on Thu, 25 Jul, 11:19 AM Test Summary: 9800 of 47197 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35317
-
Benni Mack uploaded patch set 17 11/09/19, 21:37
-
TYPO3com voted on patch set 17 V -1 11/09/19, 21:38 Completed build in 22s on Sat, 9 Nov, 09:38 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-38238
-
Benni Mack uploaded patch set 18 11/15/19, 20:22
-
TYPO3com voted on patch set 18 V -1 11/15/19, 20:24 Completed build in 31s on Fri, 15 Nov, 08:24 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-38405
-
Benni Mack uploaded patch set 19 11/22/19, 11:33
-
TYPO3com voted on patch set 19 V -1 11/22/19, 11:43 Completed build in 09m 42s on Fri, 22 Nov, 11:43 AM Test Summary: 4302 of 48429 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-38617
-
Benni Mack rebased onto patch set 20 11/22/19, 16:30
-
TYPO3com voted on patch set 20 V -1 11/22/19, 16:45 Completed build in 12m 35s on Fri, 22 Nov, 04:45 PM Test Summary: 3266 of 48448 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-38665
-
Benni Mack uploaded patch set 21 12/03/19, 14:43
-
TYPO3com voted on patch set 21 V -1 12/03/19, 14:55 Completed build in 09m 58s on Tue, 3 Dec, 02:55 PM Test Summary: 3902 of 48711 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39078
-
Benni Mack abandoned the change 04/20/20, 20:01