Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#37584 closed feature request (wontfix)

Add SHORTINIT Options

Reported by: steveglick's profile steveglick Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.3
Component: Bootstrap/Load Keywords: has-patch
Focuses: administration, performance Cc:

Description

The existing SHORTINIT variable is useful for loading a minimal WP environment, but it is far too limited for a lot of scenarios. There should be some more advanced shortinit options such as SHORTINIT_WITH_SESSION to allow access to the user session.

To give some context on where this could be useful, I built an ajax heavy WP plugin that was far too slow because of it's use of admin-ajax. To fix this I built my own ajax implementation that loads WP manually and uses SHORTINIT to do so. This removes access to user data though which removed all authentication for ajax requests. In my case this was not an option so I manually loaded in those parts of WP. This works excellently (ajax load times were cut at least in half), but I am dreading maintaining this.

This would also make it easier to implement #33252.

I'll gladly take this and build it myself if this request is approved.

Attachments (2)

WP_SHORTINIT_WITH_SESSION.patch (1.5 KB) - added by steveglick 9 years ago.
Patch to add SHORTINIT_WITH_SESSION constant
WP_SHORTINIT_FUNCTIONS.patch (3.9 KB) - added by steveglick 9 years ago.
Approach #2 using function calls after SHORTINIT than can be called manually

Download all attachments as: .zip

Change History (10)

#1 follow-up: @SergeyBiryukov
9 years ago

  • Component changed from General to Bootstrap/Load

Related/duplicate: #26806

#2 in reply to: ↑ 1 @steveglick
9 years ago

Replying to SergeyBiryukov:

Related/duplicate: #26806

Thanks for the reference Sergey, I had seen that ticket and while it is helpful in this regard, a significant difference in the approach of the mentioned ticket and this ticket is that while the mentioned ticket makes it easier to build your own ad-hoc WP loading scripts to run in addition to the SHORTINIT load, it does not fix the plugin maintainability issue I mentioned. Essentially #26806 makes it easier to build patch-work hacks on top of WP while this ticket would add several constants in addition to SHORTINIT that would tell the core what to load making plugins using the feature much more maintainable.

I should add that I do like what is proposed in #26806, and I am not trying to say that it is not a good request. It is just designed for a very different purpose than this patch.

Last edited 9 years ago by steveglick (previous) (diff)

@steveglick
9 years ago

Patch to add SHORTINIT_WITH_SESSION constant

#3 @steveglick
9 years ago

  • Keywords has-patch added

Just another thought, would a wp_load_user_session() function be a better approach? This function would be called regularly by wp_load.php after hitting the SHORT_INIT qualifier. This would allow the SHORT_INIT constant to function as it does currently, and plugin authors could simply call wp_load_user_session() manually after loading wp_load with SHORTINIT.

@steveglick
9 years ago

Approach #2 using function calls after SHORTINIT than can be called manually

#4 @steveglick
9 years ago

I much prefer the second approach. Any feedback would be appreciated.

Usage example:

/** Load WordPress Bootstrap */
define( 'SHORTINIT', true );
require_once( '../../../wp-load.php' );
wp_load_utils();
wp_load_session();
Last edited 9 years ago by steveglick (previous) (diff)

This ticket was mentioned in Slack in #core by jorbin. View the logs.


9 years ago

#6 follow-up: @jorbin
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

So many files in WordPress are cross dependent that an autoloader is the best way to ensure things get loaded. Once that is in place, custom SHORTINIT such as just handling sessions will be much more possible. #36335 is the best route for this.

#7 @steveglick
9 years ago

@jorbin I like this a lot. Hadn't seen that ticket before.

#8 in reply to: ↑ 6 @tazotodua
7 years ago

Replying to jorbin:

So many files in WordPress are cross dependent that an autoloader is the best way to ensure things get loaded. Once that is in place, custom SHORTINIT such as just handling sessions will be much more possible. #36335 is the best route for this.

sorry for replying on closed topic, but can you (anyone) tell me that a bit simpler - is that possible to use SHORTINIT, but also load ONLY user/session-functions , i.e. to check for current_user_can("manage_options")

is that possible? i cant understand that linked ticket well.

Note: See TracTickets for help on using tickets.