[wp-trac] [WordPress Trac] #27441: SHORTINIT - formatting.php required by some functions
WordPress Trac
noreply at wordpress.org
Mon Mar 17 19:47:46 UTC 2014
#27441: SHORTINIT - formatting.php required by some functions
----------------------------+-----------------------------
Reporter: jesin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bootstrap/Load | Version: 3.8.1
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
This is my first bug report with a patch file, so please correct me if I
have choosen something wrong.
When '''SHORTINIT''' is used the '''wp-includes/formatting.php''' file is
not included. Certain functions which are defined in this file are being
used by other functions. So calling any of these functions throws a
'''Fatal Error'''.
=== Examples: ===
* ''sanitize_file_name()'' is called in '''wp-includes/functions.php''' by
the function ''wp_unique_filename()''
* ''sanitize_option()'' is called in '''wp-includes/option.php''' by
several functions - ''add_option()'', ''update_option()'',
''add_site_option()'' and ''update_site_option()''
=== Reproducing this error: ===
Create a file inside the WordPress installation directory with the
following code.
{{{
<?php
define( 'SHORTINIT', true );
require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
var_dump( add_option( 'foobar', 'Hello World' ) );
?>
}}}
Access this file on the browser and the following error is displayed
(debugging should be enabled of course).
Fatal error: Call to undefined function sanitize_option() in wp-
includes/option.php on line 305
=== Workaround: ===
Manually include the file in your code.
{{{
<?php
define( 'SHORTINIT', true );
require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
require_once ABSPATH . WPINC . '/formatting.php';
var_dump( add_option( 'foobar', 'Hello World' ) );
?>
}}}
I have attached a patch which includes the formatting.php file before the
SHORTINIT check.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27441>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list