Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#51507 new defect (bug)

Ability to use as a framework

Reported by: ttodua's profile ttodua Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

WordPress provides more than 600+ framework-like functions (get_option/set_option, transcients, sanitize-functions and more, which are seen in test).
I doubt that there may be other people like our company, where we use WordPress as a backend helper framework, to make use of it's goodies (hundreds of useful functions).

As speed & performance matter, people has asked for this feature many times (i.e. example1 or example2)

It might be some useful to have one additional alternative for "SHORTINIT" constant:

  • SHORTINIT_WITHOUT_DB (to return from "wp-settings.php" right before require_wp_db())

# Performance gains #
Per my tests, compared to SHORTINIT, this approach loads wp-core about 10x faster (avoiding DB calls, etc).

Attaching the patches.

Attachments (1)

51507-1.patch (982 bytes) - added by ttodua 3 years ago.

Download all attachments as: .zip

Change History (3)

#1 @ttodua
3 years ago

To test simply:

$x= microtime(true);
define('SHORTINIT_WITHOUT_DB', true);  //as opposed to define('SHORTINIT', true); 
require(__DIR__."/src/wp-load.php");
var_dump(  microtime(true)- $x );

However, this above approach requires a dummy wp-config.php file to exist. So there might be also need to make a check in wp-config.php so as when SHORTINIT_WITHOUT_DB is set, it should not for check wp-config existence..

However, in the meanwhile to avoid any check for wp-config.php existence, this can be used as an alternative too:

...
define( 'ABSPATH', __DIR__ . '/src/' );
require(__DIR__."/src/wp-settings.php");
...

@ttodua
3 years ago

#2 @sabernhardt
3 years ago

  • Component changed from General to Bootstrap/Load

Related: #41783

Note: See TracTickets for help on using tickets.