Feature Proposal: Add a preload handler for plugins

Sometimes a decision can be made very early whether to allow a request to proceed or not; for example, on the basis of server resources, or information from the request. At the moment the earliest a decision can be made by a plugin is in the earlyInitHandler, which isn't early at al. By the time is is called the Store, the Prefs and the logged-in user are all set up - pointless, if a simple check is going to reject or shortcut the request in some way.

By splitting up some code in the Plugins.pm I was able to divide the plugin initialisation process so that plugins can be initiated very very early. This allows the addition of a new handler - I called it preload - that can perform this sort of check.

All other functionality is identical, and code performance is not impacted measurably. Nor are unit tests, which continue to operate as before; the handler is all but invisible unless it is used.

I propose to check this in for 1.2.0

-- CrawfordCurrie - 13 Feb 2013


yes please - I've used earlyInitHandler for quite a number of things, including HomePagePlugin, where it is actually somewhat risky to because too much of the session is already setup.

-- SvenDowideit - 13 Feb 2013
Topic revision: r6 - 05 Jul 2015, GeorgeClark - This page was cached on 04 Jun 2017 - 01:50.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License