From c67b2c235a4ab6953fb61e01184fa0618df35488 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 23 Jan 2020 00:27:05 +0000 Subject: [PATCH] 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 --- wp-includes/cache.php | 39 ++++++++++----------------------------- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 13 ------------- 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/wp-includes/cache.php b/wp-includes/cache.php index a5a548ccd2..ea14e78b4d 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -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; - } } diff --git a/wp-includes/version.php b/wp-includes/version.php index d0caa98ab9..22c3d2aecc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 7ea8d7f756..1bb7da4e66 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -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. *