SHOW:
|
|
- or go back to the newest paste.
1 | --- commonFiles/wordpress_from_svn/wp-includes/cache.php (revision 32479) | |
2 | +++ commonFiles/wordpress_from_svn/wp-includes/cache.php (working copy) | |
3 | @@ -24,6 +24,18 @@ | |
4 | function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { | |
5 | global $wp_object_cache; | |
6 | ||
7 | + error_log('@@@@@@@@@@@@@ wp_cache_add ############' . $key. ' ' . $group); | |
8 | + if ($key == 'alloptions') { | |
9 | + if (!is_array($data)) | |
10 | + error_log('@@@@@@@@@@@@@ wp_cache_add got non array as data ###########'); | |
11 | + $i = 0; | |
12 | + foreach($data as $k => $v) { //isn't serialized yet | |
13 | + if ($wp_object_cache->add( $k, $v, $group, $expire )) //if does not return false | |
14 | + $i++; | |
15 | + } | |
16 | + error_log("@@@@@@@@@@@@@ Added $i keys from alloptions ############"); | |
17 | + } | |
18 | + | |
19 | return $wp_object_cache->add( $key, $data, $group, (int) $expire ); | |
20 | } | |
21 | ||
22 | @@ -139,6 +151,8 @@ | |
23 | */ | |
24 | function wp_cache_init() { | |
25 | $GLOBALS['wp_object_cache'] = new WP_Object_Cache(); | |
26 | + | |
27 | + wp_load_alloptions(); //load all the options into the cache | |
28 | } | |
29 | ||
30 | - | /** |
30 | + | |
31 | ||
32 | --- commonFiles/wordpress_from_svn/wp-includes/default-widgets.php (revision 32479) | |
33 | +++ commonFiles/wordpress_from_svn/wp-includes/default-widgets.php (working copy) | |
34 | @@ -744,9 +744,10 @@ | |
35 | $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; | |
36 | $this->flush_widget_cache(); | |
37 | ||
38 | - $alloptions = wp_cache_get( 'alloptions', 'options' ); | |
39 | - if ( isset($alloptions['widget_recent_entries']) ) | |
40 | - delete_option('widget_recent_entries'); | |
41 | + //$alloptions = wp_cache_get( 'alloptions', 'options' ); | |
42 | + //if ( isset($alloptions['widget_recent_entries']) ) | |
43 | + if (wp_cache_get('widget_recent_entries', 'options')) //save db time just check cache | |
44 | + delete_option('widget_recent_entries'); //delete from DB if it existed | |
45 | ||
46 | return $instance; | |
47 | } | |
48 | @@ -897,8 +898,9 @@ | |
49 | $instance['number'] = absint( $new_instance['number'] ); | |
50 | $this->flush_widget_cache(); | |
51 | ||
52 | - $alloptions = wp_cache_get( 'alloptions', 'options' ); | |
53 | - if ( isset($alloptions['widget_recent_comments']) ) | |
54 | + //$alloptions = wp_cache_get( 'alloptions', 'options' ); | |
55 | + //if ( isset($alloptions['widget_recent_comments']) ) | |
56 | + if (wp_cache_get('widget_recent_comments', 'options')) | |
57 | delete_option('widget_recent_comments'); | |
58 | ||
59 | return $instance; | |
60 | ||
61 | ||
62 | --- commonFiles/wordpress_from_svn/wp-includes/formatting.php (revision 32479) | |
63 | +++ commonFiles/wordpress_from_svn/wp-includes/formatting.php (working copy) | |
64 | @@ -602,8 +602,9 @@ | |
65 | if ( ! $charset ) { | |
66 | static $_charset; | |
67 | if ( ! isset( $_charset ) ) { | |
68 | - $alloptions = wp_load_alloptions(); | |
69 | - $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; | |
70 | + //$alloptions = wp_load_alloptions(); | |
71 | + //$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; | |
72 | + $_charset = get_option('blog_charset', ''); //this will try the cache first | |
73 | } | |
74 | $charset = $_charset; | |
75 | } | |
76 | ||
77 | ||
78 | --- commonFiles/wordpress_from_svn/wp-includes/functions.php (revision 32479) | |
79 | +++ commonFiles/wordpress_from_svn/wp-includes/functions.php (working copy) | |
80 | @@ -1268,6 +1288,7 @@ | |
81 | return true; | |
82 | ||
83 | $suppress = $wpdb->suppress_errors(); | |
84 | +/* | |
85 | if ( ! defined( 'WP_INSTALLING' ) ) { | |
86 | $alloptions = wp_load_alloptions(); | |
87 | } | |
88 | @@ -1276,6 +1297,9 @@ | |
89 | $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); | |
90 | else | |
91 | $installed = $alloptions['siteurl']; | |
92 | +*/ | |
93 | + $installed = get_option('siteurl'); //this looks equivalent | |
94 | + | |
95 | $wpdb->suppress_errors( $suppress ); | |
96 | ||
97 | $installed = !empty( $installed ); | |
98 | ||
99 | ||
100 | ||
101 | --- commonFiles/wordpress_from_svn/wp-includes/option.php (revision 32479) | |
102 | +++ commonFiles/wordpress_from_svn/wp-includes/option.php (working copy) | |
103 | @@ -49,8 +49,11 @@ | |
104 | if ( defined( 'WP_SETUP_CONFIG' ) ) | |
105 | return false; | |
106 | ||
107 | - if ( ! defined( 'WP_INSTALLING' ) ) { | |
108 | - // prevent non-existent options from triggering multiple queries | |
109 | + if ( ! defined( 'WP_INSTALLING' ) ) { | |
110 | + | |
111 | + $value = wp_cache_get( $option, 'options' ); | |
112 | + if ( false === $value ) { //if we didn't get anything back from the cache | |
113 | + //check the notoptions | |
114 | $notoptions = wp_cache_get( 'notoptions', 'options' ); | |
115 | if ( isset( $notoptions[ $option ] ) ) { | |
116 | ||
117 | - | /** |
117 | + | |
118 | return apply_filters( 'default_option_' . $option, $default ); | |
119 | } | |
120 | ||
121 | - $alloptions = wp_load_alloptions(); | |
122 | - | |
123 | - if ( isset( $alloptions[$option] ) ) { | |
124 | - $value = $alloptions[$option]; | |
125 | - } else { | |
126 | - $value = wp_cache_get( $option, 'options' ); | |
127 | - | |
128 | - if ( false === $value ) { | |
129 | + //if we got this far, and we still don't have the value, then request from the DB | |
130 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); | |
131 | ||
132 | // Has to be get_row instead of get_var because of funkiness with 0, false, null values | |
133 | @@ -88,7 +84,6 @@ | |
134 | return apply_filters( 'default_option_' . $option, $default ); | |
135 | } | |
136 | } | |
137 | - } | |
138 | } else { | |
139 | $suppress = $wpdb->suppress_errors(); | |
140 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); | |
141 | @@ -106,8 +101,8 @@ | |
142 | return get_option( 'siteurl' ); | |
143 | ||
144 | if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) | |
145 | - $value = untrailingslashit( $value ); | |
146 | - | |
147 | + $value = rtrim( $value, '/\\' ); //$value = untrailingslashit( $value ); //untrailingslashit does not yet exist if called from within functions.php | |
148 | + | |
149 | ||
150 | @@ -284,10 +279,19 @@ | |
151 | - | * Filter the value of an existing option. |
151 | + | |
152 | do_action( 'update_option', $option, $old_value, $value ); | |
153 | ||
154 | + //what cases does $result == false? | |
155 | + //if argument 2 or 3 are not arrays | |
156 | + //prepare() returns '' if query is null (which it isnt) | |
157 | + //query() returns false if $this->ready is false | |
158 | + //also if db_connection does not exist | |
159 | + //the mysql query generated an error | |
160 | + //or if rows effected == 0 | |
161 | $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) ); | |
162 | - if ( ! $result ) | |
163 | + if ( ! $result && ! $result == 0) { //if update affected zero rows we still want to try to update the cache anyways | |
164 | return false; | |
165 | + } | |
166 | ||
167 | + //remove it from notoptions if it was there | |
168 | $notoptions = wp_cache_get( 'notoptions', 'options' ); | |
169 | if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { | |
170 | unset( $notoptions[$option] ); | |
171 | @@ -295,14 +299,14 @@ | |
172 | } | |
173 | ||
174 | if ( ! defined( 'WP_INSTALLING' ) ) { | |
175 | - $alloptions = wp_load_alloptions(); | |
176 | - if ( isset( $alloptions[$option] ) ) { | |
177 | - $alloptions[ $option ] = $serialized_value; | |
178 | - wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
179 | - } else { | |
180 | + //$alloptions = wp_load_alloptions(); | |
181 | + //if ( isset( $alloptions[$option] ) ) { | |
182 | + // $alloptions[ $option ] = $serialized_value; | |
183 | + // wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
184 | + //} else { | |
185 | wp_cache_set( $option, $serialized_value, 'options' ); | |
186 | + //} | |
187 | } | |
188 | - } | |
189 | ||
190 | ||
191 | @@ -315,7 +319,7 @@ | |
192 | ||
193 | do_action( "update_option_{$option}", $old_value, $value ); | |
194 | - | * Fires after the value of a specific option has been successfully updated. |
194 | + | |
195 | + | |
196 | - | * @param mixed $value The new option value. |
196 | + | |
197 | * Fires after the value of an option has been successfully updated. | |
198 | * | |
199 | @@ -385,22 +389,24 @@ | |
200 | */ | |
201 | do_action( 'add_option', $option, $value ); | |
202 | ||
203 | + //why on update clause, didn't we just check a bunch of times whether the option already existed? | |
204 | $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) ); | |
205 | if ( ! $result ) | |
206 | return false; | |
207 | - | |
208 | + | |
209 | if ( ! defined( 'WP_INSTALLING' ) ) { | |
210 | - if ( 'yes' == $autoload ) { | |
211 | - $alloptions = wp_load_alloptions(); | |
212 | - $alloptions[ $option ] = $serialized_value; | |
213 | - wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
214 | - } else { | |
215 | + //if ( 'yes' == $autoload ) { | |
216 | + //$alloptions = wp_load_alloptions(); | |
217 | + // $alloptions[ $option ] = $serialized_value; | |
218 | + // wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
219 | + //} else { | |
220 | wp_cache_set( $option, $serialized_value, 'options' ); | |
221 | + //} | |
222 | } | |
223 | - } | |
224 | ||
225 | // This option exists now | |
226 | $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh | |
227 | + //but why must it be fresh? I guess another query might have run in the meantime? | |
228 | if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { | |
229 | unset( $notoptions[$option] ); | |
230 | wp_cache_set( 'notoptions', $notoptions, 'options' ); | |
231 | @@ -449,6 +455,7 @@ | |
232 | wp_protect_special_option( $option ); | |
233 | ||
234 | // Get the ID, if no ID then return | |
235 | + //checking if the option exists to be deleted | |
236 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); | |
237 | if ( is_null( $row ) ) | |
238 | return false; | |
239 | @@ -464,18 +471,22 @@ | |
240 | ||
241 | $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); | |
242 | if ( ! defined( 'WP_INSTALLING' ) ) { | |
243 | - if ( 'yes' == $row->autoload ) { | |
244 | - $alloptions = wp_load_alloptions(); | |
245 | - if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) { | |
246 | - unset( $alloptions[$option] ); | |
247 | - wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
248 | - } | |
249 | - } else { | |
250 | + //if ( 'yes' == $row->autoload ) { | |
251 | + // $alloptions = wp_load_alloptions(); | |
252 | + // if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) { | |
253 | + // unset( $alloptions[$option] ); | |
254 | + // wp_cache_set( 'alloptions', $alloptions, 'options' ); | |
255 | + // } | |
256 | + //} else { | |
257 | wp_cache_delete( $option, 'options' ); | |
258 | + //} | |
259 | } | |
260 | - } | |
261 | if ( $result ) { | |
262 | - | |
263 | + //now to pre-emptively cache the negative result of the newly deleted option | |
264 | + $notoptions = wp_cache_get( 'notoptions', 'options' ); | |
265 | + $notoptions[$option] = true; | |
266 | + wp_cache_set( 'notoptions', $notoptions, 'options' ); | |
267 | + | |
268 | /** | |
269 | * Fires after a specific option has been deleted. | |
270 | * |