Make WordPress Core

Changeset 47107

Timestamp:
01/23/2020 12:25:38 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cache.php

    r47060 r47107  
    337337
    338338    /**
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
    339349     * Makes private properties readable for backward compatibility.
    340350     *
     
    727737        return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
    728738    }
    729 
    730     /**
    731      * Sets up object properties; PHP 5 style constructor.
    732      *
    733      * @since 2.0.8
    734      */
    735     public function __construct() {
    736         $this->multisite   = is_multisite();
    737         $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
    738 
    739         /**
    740          * @todo This should be moved to the PHP4 style constructor, PHP5
    741          * already calls __destruct()
    742          */
    743         register_shutdown_function( array( $this, '__destruct' ) );
    744     }
    745 
    746     /**
    747      * Saves the object cache before object is completely destroyed.
    748      *
    749      * Called upon object destruction, which should be when PHP ends.
    750      *
    751      * @since 2.0.8
    752      *
    753      * @return true Always returns true.
    754      */
    755     public function __destruct() {
    756         return true;
    757     }
    758 }
     739}
  • trunk/src/wp-includes/wp-db.php

    r47088 r47107  
    605605     */
    606606    public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
    607         register_shutdown_function( array( $this, '__destruct' ) );
    608 
    609607        if ( WP_DEBUG && WP_DEBUG_DISPLAY ) {
    610608            $this->show_errors();
     
    631629
    632630        $this->db_connect();
    633     }
    634 
    635     /**
    636      * PHP5 style destructor and will run when database object is destroyed.
    637      *
    638      * @see wpdb::__construct()
    639      * @since 2.0.8
    640      * @return true
    641      */
    642     public function __destruct() {
    643         return true;
    644631    }
    645632
Note: See TracChangeset for help on using the changeset viewer.