Cache API: Remove WP_Object_Cache::__destruct() and wpdb::__destruct().

Originally added in [4686], these constructor/destructor pairings were designed to prevent the objects from being destroyed before shutdown, when output buffers are flushed.

A deeper investigation reveals that this approach didn't quite work as expected and was later made redundant by introducing `wp_ob_end_flush_all()` in [5462].

Props wonderboymusic, nacin, Mte90, SergeyBiryukov.
Fixes #21402.
Built from https://develop.svn.wordpress.org/trunk@47107


git-svn-id: http://core.svn.wordpress.org/trunk@46907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-01-23 00:27:05 +00:00
parent 48299521c6
commit c67b2c235a
3 changed files with 11 additions and 43 deletions

View File

@ -335,6 +335,16 @@ class WP_Object_Cache {
*/
private $multisite;
/**
* Sets up object properties; PHP 5 style constructor.
*
* @since 2.0.8
*/
public function __construct() {
$this->multisite = is_multisite();
$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
}
/**
* Makes private properties readable for backward compatibility.
*
@ -726,33 +736,4 @@ class WP_Object_Cache {
protected function _exists( $key, $group ) {
return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
}
/**
* Sets up object properties; PHP 5 style constructor.
*
* @since 2.0.8
*/
public function __construct() {
$this->multisite = is_multisite();
$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
/**
* @todo This should be moved to the PHP4 style constructor, PHP5
* already calls __destruct()
*/
register_shutdown_function( array( $this, '__destruct' ) );
}
/**
* Saves the object cache before object is completely destroyed.
*
* Called upon object destruction, which should be when PHP ends.
*
* @since 2.0.8
*
* @return true Always returns true.
*/
public function __destruct() {
return true;
}
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-47106';
$wp_version = '5.4-alpha-47107';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -604,8 +604,6 @@ class wpdb {
* @param string $dbhost MySQL database host
*/
public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
register_shutdown_function( array( $this, '__destruct' ) );
if ( WP_DEBUG && WP_DEBUG_DISPLAY ) {
$this->show_errors();
}
@ -632,17 +630,6 @@ class wpdb {
$this->db_connect();
}
/**
* PHP5 style destructor and will run when database object is destroyed.
*
* @see wpdb::__construct()
* @since 2.0.8
* @return true
*/
public function __destruct() {
return true;
}
/**
* Makes private properties readable for backward compatibility.
*