WordPress.org

Make WordPress Core

Changeset 28502


Ignore:
Timestamp:
05/19/2014 05:15:20 AM (7 years ago)
Author:
wonderboymusic
Message:

Add access modifiers to methods/members in WP_Object_Cache. Add a magic __get() method for BC.

See #27881.

File:
1 edited

Legend:

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

    r27162 r28502  
    269269     * @since 2.0.0
    270270     */
    271     var $cache = array ();
     271    private $cache = array ();
    272272
    273273    /**
     
    278278     * @var int
    279279     */
    280     var $cache_hits = 0;
     280    private $cache_hits = 0;
    281281
    282282    /**
     
    287287     * @since 2.0.0
    288288     */
    289     var $cache_misses = 0;
     289    public $cache_misses = 0;
    290290
    291291    /**
     
    296296     * @since 3.0.0
    297297     */
    298     var $global_groups = array();
     298    protected $global_groups = array();
    299299
    300300    /**
     
    305305     * @since 3.5.0
    306306     */
    307     var $blog_prefix;
     307    private $blog_prefix;
     308
     309    /**
     310     * Make private properties readable for backwards compatibility
     311     *
     312     * @since 4.0.0
     313     * @param string $name
     314     * @return mixed
     315     */
     316    public function __get( $name ) {
     317        return $this->$name;
     318    }
    308319
    309320    /**
     
    322333     * @return bool False if cache key and group already exist, true on success
    323334     */
    324     function add( $key, $data, $group = 'default', $expire = 0 ) {
     335    public function add( $key, $data, $group = 'default', $expire = 0 ) {
    325336        if ( wp_suspend_cache_addition() )
    326337            return false;
     
    346357     * @param array $groups List of groups that are global.
    347358     */
    348     function add_global_groups( $groups ) {
     359    public function add_global_groups( $groups ) {
    349360        $groups = (array) $groups;
    350361
     
    363374     * @return false|int False on failure, the item's new value on success.
    364375     */
    365     function decr( $key, $offset = 1, $group = 'default' ) {
     376    public function decr( $key, $offset = 1, $group = 'default' ) {
    366377        if ( empty( $group ) )
    367378            $group = 'default';
     
    399410     * @return bool False if the contents weren't deleted and true on success
    400411     */
    401     function delete( $key, $group = 'default', $deprecated = false ) {
     412    public function delete( $key, $group = 'default', $deprecated = false ) {
    402413        if ( empty( $group ) )
    403414            $group = 'default';
     
    420431     * @return bool Always returns true
    421432     */
    422     function flush() {
     433    public function flush() {
    423434        $this->cache = array ();
    424435
     
    443454     *      contents on success
    444455     */
    445     function get( $key, $group = 'default', $force = false, &$found = null ) {
     456    public function get( $key, $group = 'default', $force = false, &$found = null ) {
    446457        if ( empty( $group ) )
    447458            $group = 'default';
     
    474485     * @return false|int False on failure, the item's new value on success.
    475486     */
    476     function incr( $key, $offset = 1, $group = 'default' ) {
     487    public function incr( $key, $offset = 1, $group = 'default' ) {
    477488        if ( empty( $group ) )
    478489            $group = 'default';
     
    509520     * @return bool False if not exists, true if contents were replaced
    510521     */
    511     function replace( $key, $data, $group = 'default', $expire = 0 ) {
     522    public function replace( $key, $data, $group = 'default', $expire = 0 ) {
    512523        if ( empty( $group ) )
    513524            $group = 'default';
     
    529540     * @deprecated 3.5.0
    530541     */
    531     function reset() {
     542    public function reset() {
    532543        _deprecated_function( __FUNCTION__, '3.5', 'switch_to_blog()' );
    533544
     
    559570     * @return bool Always returns true
    560571     */
    561     function set( $key, $data, $group = 'default', $expire = 0 ) {
     572    public function set( $key, $data, $group = 'default', $expire = 0 ) {
    562573        if ( empty( $group ) )
    563574            $group = 'default';
     
    581592     * @since 2.0.0
    582593     */
    583     function stats() {
     594    public function stats() {
    584595        echo "<p>";
    585596        echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
     
    602613     * @param int $blog_id Blog ID
    603614     */
    604     function switch_to_blog( $blog_id ) {
     615    public function switch_to_blog( $blog_id ) {
    605616        $blog_id = (int) $blog_id;
    606617        $this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
     
    624635     * @return null|WP_Object_Cache If cache is disabled, returns null.
    625636     */
    626     function __construct() {
     637    public function __construct() {
    627638        global $blog_id;
    628639
     
    647658     * @return bool True value. Won't be used by PHP
    648659     */
    649     function __destruct() {
     660    public function __destruct() {
    650661        return true;
    651662    }
Note: See TracChangeset for help on using the changeset viewer.