Bug #23597 Clarification Requested

Use of end_script in hook ends all current running hooks including nested hooks

Version: 4.2.1 Reporter: ACER

The use of ee()->extensions->end_script within a function attached to an extension hook ends all currently running hooks and not just the current one. Any function that is triggered by a hook that itself triggers the call of a hook will show this problem if the nested hook functions use end_script=true.

This appears to manifest itself most commonly when using an extension that uses the session_start hook and another extension that uses the set_cookie_end. As the use of set_cookie_end nearly always requires the use of end_script to override the default behaviour is why they clash so often. The setting of the end_script flag causes not only the set_cookie_end hook loop to exit but also the session_start loop. This causes the session to be incomplete in its setup and will offline the site. As the session_start functions use the Input->set_cookie function which in turn calls the set_cookie_end hook it results in a nested call of extension hooks.

I don’t believe that this behaviour is intentional as it makes the use of session affecting and cookie setting plugins incompatible. Ideally, end_script should only exit the current hook.

I’ve put together a patch that I believe addresses the problem without breaking any existing code.

https://gist.github.com/ericharth/8ba9eb0767ead2456af093c751ec9ab5

If the end_script is working as intended then the set_cookie_end hook needs changing so that the $data can be modified before the data is set, otherwise, we can’t override the base functionality.

This is related to the bug reported https://expressionengine.com/support/bugs/18088/cookie_consent_module_setting_system_to_offline

Thanks Eric

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases