Well I'm speaking without knowledge of the inner workings of the dispatcher, but you probably have a
core.assign_block_vars
,
core.assign_vars
and a
core.assign_var
event. Then a MOD author must know through which method his data comes in, pretty much like he currently must know which event to use.
However during trying this I found that this isn't possible in the current system, but it also appears that the dispatcher can't actually handle the
core.viewtopic_postrow
event. Here is an IRC log of an discussion between UKB and myself
Code: Select all
unknownbliss: erikfrerejean: replied
[9:11pm] erikfrerejean: unknownbliss: which problem?
[9:11pm] unknownbliss: assign_vars and assign_var can be overwritten with current hooks. assign_block_vars i have no idea how you'll event that as its inside a loop
[9:11pm] unknownbliss: Well its inside a loop....
[9:12pm] erikfrerejean: So is `core.viewtopic_postrow`
[9:12pm] erikfrerejean: it is however called before the template call, rather than in this case in the template call
[9:13pm] erikfrerejean: only the location of the dispatcher call changes nothing else (or at least should)
[9:14pm] erikfrerejean: I don't think (with my limited understanding of the new template/event systems) there is a difference in there
[9:14pm] unknownbliss: I can't remember off the top of my head
[9:15pm] unknownbliss: and im not sure how to describe it
[9:15pm] erikfrerejean: What is the difference between calling the event the line *before* `$template->assign_block_vars(….)`, or on the first line of that method?
[9:15pm] erikfrerejean: If the loop is an issue then the `core.viewtopic_postrow` event can't work to begin with
[9:16pm] erikfrerejean: Only the call point slightly changes, nothing else
[9:17pm] erikfrerejean: It would be really weird, if that change somehow breaks the event dispatcher
[9:18pm] unknownbliss: it can
[9:19pm] unknownbliss: outside the loop the variable you want to edit is an array and easy to edit
[9:19pm] unknownbliss: once its inside the loop its one element of the array which you can't edit it in the same way
[9:19pm] unknownbliss: so you have to modify the var being put in the loop before its in the loop
[9:20pm] unknownbliss: once its in the loop you can't do anything with it
[9:20pm] unknownbliss: thing if you add something to the array
[9:20pm] unknownbliss: then you also need an even in the array to be able to add it to the assign_block_vars
[9:20pm] unknownbliss: I'm explaining this really badly
[9:21pm] erikfrerejean: What loop? https://github.com/p/phpbb3/blob/8eaa3e003c99efe4173370a475a7b2d2a6df2c5d/phpBB/viewtopic.php#L1586 *is* already in the loop
[9:21pm] unknownbliss: assign_block_vars can't be called twice for the same thing iirc
[9:21pm] erikfrerejean: Remove that event and add an event on the first line of `assign_block_vars` with the same parameters. Then nothing changes in the setup
[9:22pm] erikfrerejean: So either the current behavior is already broken or there is no issue
[9:31pm] erikfrerejean: I'm not seeing the issue.
[9:31pm] • erikfrerejean goes out and builds an POC
[9:33pm] unknownbliss: ok
[9:33pm] unknownbliss: it may be im just being a nub
[9:44pm] erikfrerejean: unknownbliss: so no it doesn't work, though the normal behavior is broken as well. Altering the event data in the `core.viewtopic_postrow` event throws an "[phpBB Debug] PHP Notice: in file [ROOT]/ext/test/event/test_listener.php on line 16: Indirect modification of overloaded element of phpbb_event_data has no effect"
[9:44pm] erikfrerejean: And adding an event inside that method does the same thing.
[9:44pm] unknownbliss: ah right
[9:44pm] erikfrerejean: So I'm right on the theory that it is the same but obviously the current behavior is broken
[9:44pm] unknownbliss: feel free to deal with it, I can't at the moment. I've got so much to do and I'm on holiday. :P
[9:45pm] erikfrerejean: Well I can't neither and don't have the time to dig into the magic that is the event dispatcher.
I'll commit POC code in a bit, so someone with a deeper understanding of the system can see whether I messed something up or whether this indeed is a problem within the dispatcher. The events I used can be found in
this gist