Hello

I want suggest to give the other modules opportunity to do some actions with context handler, before it would be rendered. It will be very useful for some logic, which can check or modify data in context handler.
In my case I need custom checking and new hook will be very useful for me.

Comments

eugene.ilyin created an issue. See original summary.

eugene.ilyin’s picture

I've prepared a patch for this functionality

Thank you!

eugene.ilyin’s picture

Can somebody review it please?

rivimey’s picture

The patch looks ok, and it is good that you have added the .api doc for it.

The text of the comment could be improved. It would be good, also, to include some details about what can be found in the handler object at this point in the request's life, and note if there are things that must not be changed (likely because decisions have already been taken based on the current value).

- * Let the other modules do some actions before than context handler would be rendered.
+ * Let other modules modify the context handler before it is rendered.

On a wider point, I am not sure it is good to include a new hook in ctools at this point in the release cycle. I can see that for some users it will be very useful, and of course we have several years of D7 life left, but still... Any thoughts from others?

eugene.ilyin’s picture

The text of the comment could be improved.

Thank you. I updated patch

It would be good, also, to include some details about what can be found in the handler object at this point in the request's life, and note if there are things that must not be changed (likely because decisions have already been taken based on the current value).

I'm not sure about it. Handler is a stdclass object with a lot of properties. We shouldn't change did, name or task properties, but I don't think that we need an explanation about it.

On a wider point, I am not sure it is good to include a new hook in ctools at this point in the release cycle. I can see that for some users it will be very useful, and of course we have several years of D7 life left, but still... Any thoughts from others?

I think that this my proposition is better than current state of the function:
function ctools_context_handler_pre_render($handler, $contexts, $args) { }
it looks unnecessary

eugene.ilyin’s picture

rivimey’s picture

Thanks for the revision, it looks good.

I also agree that the existing pre_render function appears to be pointless, and that what you propose is better than that. My concern is mostly that we're adding new code paths to a module that is already a maze of poorly understood code, and irrespective of the merits of a specific change, adding new code paths to that seems the wrong way to go.

I have had a look into why ctools_context_handler_pre_render is empty. The function, previously added in 2010 by Sam Boyer (history unknown) was then deleted in Issue 1191566 by a change that included @MerlinofChaos, @Dawehner and @DaveReid. The reason the function was not deleted entirely was: "Quick review: Can't remove ctools_context_handler_pre_render() -- it can be empty, though. But it gets called externally, removing it would break API." Given this, it is possible there is still code that expects this function to do something other than call new handler functions. it would be stupid code, but still...

In summary I don't think this change should be accepted as-is without several other people chipping in confirming it would be both safe and useful.

rivimey’s picture

Status: Needs review » Reviewed & tested by the community
Parent issue: » #2828925: Plan for CTools 7.x-1.13 release

Proposing RTBC for the next 'features' release - 1.13 - with the proviso that @japerry agrees this is a good thing to do.

rivimey’s picture

Assigned: eugene.ilyin » Unassigned
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Aye I agree. Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.