Ticket #21402: format-cache.diff

File format-cache.diff, 6.5 KB (added by wonderboymusic, 10 months ago)
Line 
1Index: wp-includes/cache.php
2===================================================================
3--- wp-includes/cache.php       (revision 21358)
4+++ wp-includes/cache.php       (working copy)
5@@ -21,10 +21,10 @@
6  * @param int $expire When the cache data should be expired
7  * @return unknown
8  */
9-function wp_cache_add($key, $data, $group = '', $expire = 0) {
10+function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
11        global $wp_object_cache;
12 
13-       return $wp_object_cache->add($key, $data, $group, $expire);
14+       return $wp_object_cache->add( $key, $data, $group, $expire );
15 }
16 
17 /**
18@@ -72,10 +72,10 @@
19  * @param string $group Where the cache contents are grouped
20  * @return bool True on successful removal, false on failure
21  */
22-function wp_cache_delete($key, $group = '') {
23+function wp_cache_delete( $key, $group = '' ) {
24        global $wp_object_cache;
25 
26-       return $wp_object_cache->delete($key, $group);
27+       return $wp_object_cache->delete( $key, $group );
28 }
29 
30 /**
31@@ -154,10 +154,10 @@
32  * @param int $expire When to expire the cache contents
33  * @return bool False if cache key and group already exist, true on success
34  */
35-function wp_cache_replace($key, $data, $group = '', $expire = 0) {
36+function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
37        global $wp_object_cache;
38 
39-       return $wp_object_cache->replace($key, $data, $group, $expire);
40+       return $wp_object_cache->replace( $key, $data, $group, $expire );
41 }
42 
43 /**
44@@ -173,10 +173,10 @@
45  * @param int $expire When to expire the cache contents
46  * @return bool False if cache key and group already exist, true on success
47  */
48-function wp_cache_set($key, $data, $group = '', $expire = 0) {
49+function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
50        global $wp_object_cache;
51 
52-       return $wp_object_cache->set($key, $data, $group, $expire);
53+       return $wp_object_cache->set( $key, $data, $group, $expire );
54 }
55 
56 /**
57@@ -189,7 +189,7 @@
58 function wp_cache_add_global_groups( $groups ) {
59        global $wp_object_cache;
60 
61-       return $wp_object_cache->add_global_groups($groups);
62+       return $wp_object_cache->add_global_groups( $groups );
63 }
64 
65 /**
66@@ -241,7 +241,7 @@
67         * @access private
68         * @since 2.0.0
69         */
70-       var $cache = array ();
71+       var $cache = array();
72 
73        /**
74         * The amount of times the cache data was already stored in the cache.
75@@ -292,10 +292,10 @@
76                if ( empty( $group ) )
77                        $group = 'default';
78 
79-               if ( $this->_exists($key, $group) )
80+               if ( $this->_exists( $key, $group ) )
81                        return false;
82 
83-               return $this->set($key, $data, $group, $expire);
84+               return $this->set( $key, $data, $group, $expire );
85        }
86 
87        /**
88@@ -308,8 +308,8 @@
89        function add_global_groups( $groups ) {
90                $groups = (array) $groups;
91 
92-               $this->global_groups = array_merge($this->global_groups, $groups);
93-               $this->global_groups = array_unique($this->global_groups);
94+               $this->global_groups = array_merge( $this->global_groups, $groups );
95+               $this->global_groups = array_unique( $this->global_groups );
96        }
97 
98        /**
99@@ -357,14 +357,14 @@
100         *              key in the group
101         * @return bool False if the contents weren't deleted and true on success
102         */
103-       function delete($key, $group = 'default', $force = false) {
104+       function delete( $key, $group = 'default', $force = false ) {
105                if ( empty( $group ) )
106                        $group = 'default';
107 
108                if ( ! $force && ! $this->_exists( $key, $group ) )
109                        return false;
110 
111-               unset( $this->cache[$group][$key] );
112+               unset( $this->cache[ $group ][ $key ] );
113                return true;
114        }
115 
116@@ -376,7 +376,7 @@
117         * @return bool Always returns true
118         */
119        function flush() {
120-               $this->cache = array ();
121+               $this->cache = array();
122 
123                return true;
124        }
125@@ -405,10 +405,10 @@
126                if ( $this->_exists( $key, $group ) ) {
127                        $found = true;
128                        $this->cache_hits += 1;
129-                       if ( is_object($this->cache[$group][$key]) )
130-                               return clone $this->cache[$group][$key];
131+                       if ( is_object( $this->cache[ $group ][ $key ] ) )
132+                               return clone $this->cache[ $group ][ $key ];
133                        else
134-                               return $this->cache[$group][$key];
135+                               return $this->cache[ $group ][ $key ];
136                }
137 
138                $found = false;
139@@ -458,14 +458,14 @@
140         * @param int $expire When to expire the cache contents
141         * @return bool False if not exists, true if contents were replaced
142         */
143-       function replace($key, $data, $group = 'default', $expire = '') {
144+       function replace( $key, $data, $group = 'default', $expire = '' ) {
145                if ( empty( $group ) )
146                        $group = 'default';
147 
148                if ( ! $this->_exists( $key, $group ) )
149                        return false;
150 
151-               return $this->set($key, $data, $group, $expire);
152+               return $this->set( $key, $data, $group, $expire );
153        }
154 
155        /**
156@@ -475,9 +475,9 @@
157         */
158        function reset() {
159                // Clear out non-global caches since the blog ID has changed.
160-               foreach ( array_keys($this->cache) as $group ) {
161-                       if ( !in_array($group, $this->global_groups) )
162-                               unset($this->cache[$group]);
163+               foreach ( array_keys( $this->cache ) as $group ) {
164+                       if ( !in_array( $group, $this->global_groups ) )
165+                               unset( $this->cache[ $group ] );
166                }
167        }
168 
169@@ -501,14 +501,14 @@
170         * @param int $expire Not Used
171         * @return bool Always returns true
172         */
173-       function set($key, $data, $group = 'default', $expire = '') {
174+       function set( $key, $data, $group = 'default', $expire = '' ) {
175                if ( empty( $group ) )
176                        $group = 'default';
177 
178-               if ( is_object($data) )
179+               if ( is_object( $data ) )
180                        $data = clone $data;
181 
182-               $this->cache[$group][$key] = $data;
183+               $this->cache[ $group ][ $key ] = $data;
184                return true;
185        }
186 
187@@ -526,7 +526,7 @@
188                echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
189                echo "</p>";
190                echo '<ul>';
191-               foreach ($this->cache as $group => $cache) {
192+               foreach ( $this->cache as $group => $cache ) {
193                        echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>';
194                }
195                echo '</ul>';
196@@ -542,31 +542,4 @@
197        protected function _exists( $key, $group ) {
198                return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
199        }
200-
201-       /**
202-        * Sets up object properties; PHP 5 style constructor
203-        *
204-        * @since 2.0.8
205-        * @return null|WP_Object_Cache If cache is disabled, returns null.
206-        */
207-       function __construct() {
208-               /**
209-                * @todo This should be moved to the PHP4 style constructor, PHP5
210-                * already calls __destruct()
211-                */
212-               register_shutdown_function(array(&$this, "__destruct"));
213-       }
214-
215-       /**
216-        * Will save the object cache before object is completely destroyed.
217-        *
218-        * Called upon object destruction, which should be when PHP ends.
219-        *
220-        * @since  2.0.8
221-        *
222-        * @return bool True value. Won't be used by PHP
223-        */
224-       function __destruct() {
225-               return true;
226-       }
227 }