Ticket #44467: 44467.2.diff
File 44467.2.diff, 20.4 KB (added by , 7 years ago) |
---|
-
src/wp-includes/comment.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
441 441 * @return int|bool Meta ID on success, false on failure. 442 442 */ 443 443 function add_comment_meta( $comment_id, $meta_key, $meta_value, $unique = false ) { 444 $added = add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique ); 445 if ( $added ) { 446 wp_cache_set( 'last_changed', microtime(), 'comment' ); 447 } 448 return $added; 444 return add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique ); 449 445 } 450 446 451 447 /** … … 464 460 * @return bool True on success, false on failure. 465 461 */ 466 462 function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) { 467 $deleted = delete_metadata( 'comment', $comment_id, $meta_key, $meta_value ); 468 if ( $deleted ) { 469 wp_cache_set( 'last_changed', microtime(), 'comment' ); 470 } 471 return $deleted; 463 return delete_metadata( 'comment', $comment_id, $meta_key, $meta_value ); 472 464 } 473 465 474 466 /** … … 505 497 * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. 506 498 */ 507 499 function update_comment_meta( $comment_id, $meta_key, $meta_value, $prev_value = '' ) { 508 $updated = update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value ); 509 if ( $updated ) { 510 wp_cache_set( 'last_changed', microtime(), 'comment' ); 511 } 512 return $updated; 500 return update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value ); 513 501 } 514 502 515 503 /** -
src/wp-includes/default-filters.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
97 97 98 98 // Meta 99 99 add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 ); 100 add_action( 'add_metadata', 'clean_object_last_changed', 10, 2 ); 101 add_action( 'update_metadata', 'clean_object_last_changed', 10, 2 ); 102 add_action( 'delete_metadata', 'clean_object_last_changed', 10, 2 ); 103 104 add_filter( 'update_term_metadata', '_disable_term_meta', 10, 1 ); 105 add_filter( 'add_term_metadata', '_disable_term_meta', 10, 1 ); 106 add_filter( 'delete_term_metadata', '_disable_term_meta', 10, 1 ); 107 add_filter( 'get_term_metadata', '_disable_term_meta', 10, 1 ); 108 add_filter( 'update_term_meta_cache', '_disable_term_meta', 10, 1 ); 109 110 add_filter( 'update_term_metadata', '_check_shared_term_meta', 10, 2 ); 111 add_filter( 'add_term_metadata', '_check_shared_term_meta', 10, 2 ); 112 add_filter( 'delete_term_metadata', '_check_shared_term_meta', 10, 2 ); 113 100 114 101 115 // Places to balance tags on input 102 116 foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { -
src/wp-includes/functions.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
4798 4798 return (bool) $supported; 4799 4799 } 4800 4800 4801 4802 /** 4803 * Determines whether term meta is enabled. 4804 * 4805 * @since x.x.x 4806 4807 * 4808 * @return bool True if term meta is supported, false otherwise. 4809 */ 4810 function is_term_meta_supported() { 4811 return ( get_option( 'db_version' ) < 34370 ); 4812 } 4813 4801 4814 /** 4802 4815 * gmt_offset modification for smart timezone handling. 4803 4816 * -
src/wp-includes/meta.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
131 131 */ 132 132 do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value ); 133 133 134 /** 135 * Fires immediately after meta of a specific type is added. 136 * 137 * 138 * @since x.x.x 139 * 140 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) 141 * @param int $object_id ID of the object metadata is for 142 * @param string $meta_key Metadata key 143 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. 144 * @param bool $unique Optional, default is false. 145 * Whether the specified metadata key should be unique for the object. 146 * If true, and the object already has a value for the specified metadata key, 147 * no change will be made. 148 */ 149 do_action( "add_metadata", $meta_type, $object_id, $meta_key, $meta_value, $unique ); 150 134 151 return $mid; 135 152 } 136 153 … … 299 316 } 300 317 } 301 318 319 /** 320 * Fires immediately after updating metadata of a specific type. 321 * 322 * @since x.x.x 323 * 324 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) 325 * @param int $object_id ID of the object metadata is for 326 * @param string $meta_key Metadata key 327 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. 328 */ 329 do_action( "update_metadata", $meta_type, $object_id, $meta_key, $_meta_value ); 330 302 331 return true; 303 332 } 304 333 … … 463 492 do_action( 'deleted_postmeta', $meta_ids ); 464 493 } 465 494 495 /** 496 * Fires immediately after deleting metadata of a specific type. 497 * 498 * @since x.x.x 499 * 500 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) 501 * @param int $object_id ID of the object metadata is for 502 * @param string $meta_key Metadata key 503 * @param mixed $meta_value Optional. Metadata value. Must be serializable if non-scalar. If specified, only delete 504 * metadata entries with this value. Otherwise, delete all entries with the specified meta_key. 505 * Pass `null`, `false`, or an empty string to skip this check. (For backward compatibility, 506 * it is not possible to pass an empty string to delete those entries with an empty string 507 * for a value.) 508 * @param bool $delete_all Optional, default is false. If true, delete matching metadata entries for all objects, 509 * ignoring the specified object_id. Otherwise, only delete matching metadata entries for 510 * the specified object_id. 511 */ 512 do_action( "delete_metadata", $meta_type, $object_id, $meta_key, $meta_value, $delete_all ); 513 466 514 return true; 467 515 } 468 516 … … 707 755 /** This action is documented in wp-includes/meta.php */ 708 756 do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); 709 757 758 /** This action is documented in wp-includes/meta.php */ 759 do_action( "update_metadata", $meta_type, $object_id, $meta_key, $_meta_value ); 760 710 761 if ( 'post' == $meta_type ) { 711 762 /** This action is documented in wp-includes/meta.php */ 712 763 do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); … … 783 834 /** This action is documented in wp-includes/meta.php */ 784 835 do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); 785 836 837 /** This action is documented in wp-includes/meta.php */ 838 do_action( "delete_metadata", $meta_type, $object_id, $meta->meta_key, $meta->meta_value , false ); 839 786 840 // Old-style action. 787 841 if ( 'post' == $meta_type || 'comment' == $meta_type ) { 788 842 /** … … 841 895 $cache_key = $meta_type . '_meta'; 842 896 $ids = array(); 843 897 $cache = array(); 844 foreach ( $object_ids as $id ) { 845 $cached_object = wp_cache_get( $id, $cache_key ); 898 foreach ( $object_ids as $object_id ) { 899 /** 900 * Filters whether to update metadata cache of a specific type. 901 * 902 * @since x.x.x 903 * 904 * @param null|bool $check Whether to allow updating metadata cache for the given type. 905 * @param int $object_id Object ID. 906 **/ 907 $check = apply_filters( "update_{$meta_type}_meta_cache", null, $object_id ); 908 if ( null !== $check ) { 909 return (bool) $check; 910 } 911 912 $cached_object = wp_cache_get( $object_id, $cache_key ); 846 913 if ( false === $cached_object ) { 847 $ids[] = $ id;914 $ids[] = $object_id; 848 915 } else { 849 $cache[ $ id ] = $cached_object;916 $cache[ $object_id ] = $cached_object; 850 917 } 851 918 } 852 919 … … 1360 1427 */ 1361 1428 return apply_filters( "get_object_subtype_{$object_type}", $object_subtype, $object_id ); 1362 1429 } 1430 1431 1432 /** 1433 * 1434 * @since x.x.x 1435 * 1436 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) 1437 * @param int $object_id ID of the object. 1438 * @return bool 1439 */ 1440 function clean_object_last_changed( $meta_type, $object_id = 0 ) { 1441 switch ( $meta_type ) { 1442 case 'blog': 1443 $group = 'sites'; 1444 break; 1445 case 'user': 1446 $group = 'users'; 1447 break; 1448 case 'term': 1449 $group = 'terms'; 1450 break; 1451 case 'comment': 1452 $group = 'comment'; 1453 break; 1454 case 'post': 1455 $group = 'posts'; 1456 break; 1457 default: 1458 $group = false; 1459 break; 1460 } 1461 1462 /** 1463 * 1464 * @since x.x.x 1465 * 1466 * @param string $group Group string to override. 1467 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) 1468 * @param int $object_id ID of the object to get the subtype for. 1469 */ 1470 $group = apply_filters( "get_object_cache_group", $group, $meta_type, $object_id ); 1471 1472 if ( ! $group ) { 1473 return false; 1474 } 1475 1476 return wp_cache_set( 'last_changed', microtime(), $group ); 1477 } 1478 No newline at end of file -
src/wp-includes/ms-blogs.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
618 618 * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success. 619 619 */ 620 620 function update_sitemeta_cache( $site_ids ) { 621 return update_meta_cache( 'blog', $site_ids ); 622 } 623 624 /** 625 * @param $value 626 * 627 * @return mixed 628 */ 629 function _disable_site_meta( $value ) { 621 630 if ( ! is_site_meta_supported() ) { 622 631 return false; 623 632 } 624 633 625 return update_meta_cache( 'blog', $site_ids );634 return $value; 626 635 } 627 636 628 637 /** … … 838 847 * @return int|false Meta ID on success, false on failure. 839 848 */ 840 849 function add_site_meta( $site_id, $meta_key, $meta_value, $unique = false ) { 841 // Bail if site meta table is not installed. 842 if ( ! is_site_meta_supported() ) { 843 /* translators: %s: database table name */ 844 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.0.0' ); 845 return false; 846 } 847 848 $added = add_metadata( 'blog', $site_id, $meta_key, $meta_value, $unique ); 849 850 // Bust site query cache. 851 if ( $added ) { 852 wp_cache_set( 'last_changed', microtime(), 'sites' ); 853 } 854 855 return $added; 850 return add_metadata( 'blog', $site_id, $meta_key, $meta_value, $unique ); 856 851 } 857 852 858 853 /** … … 871 866 * @return bool True on success, false on failure. 872 867 */ 873 868 function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) { 874 // Bail if site meta table is not installed. 875 if ( ! is_site_meta_supported() ) { 876 /* translators: %s: database table name */ 877 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.0.0' ); 878 return false; 879 } 880 881 $deleted = delete_metadata( 'blog', $site_id, $meta_key, $meta_value ); 882 883 // Bust site query cache. 884 if ( $deleted ) { 885 wp_cache_set( 'last_changed', microtime(), 'sites' ); 886 } 887 888 return $deleted; 869 return delete_metadata( 'blog', $site_id, $meta_key, $meta_value ); 889 870 } 890 871 891 872 /** … … 901 882 * field if $single is true. 902 883 */ 903 884 function get_site_meta( $site_id, $key = '', $single = false ) { 904 // Bail if site meta table is not installed.905 if ( ! is_site_meta_supported() ) {906 /* translators: %s: database table name */907 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.0.0' );908 return false;909 }910 911 885 return get_metadata( 'blog', $site_id, $key, $single ); 912 886 } 913 887 … … 930 904 * false on failure. 931 905 */ 932 906 function update_site_meta( $site_id, $meta_key, $meta_value, $prev_value = '' ) { 933 // Bail if site meta table is not installed. 934 if ( ! is_site_meta_supported() ) { 935 /* translators: %s: database table name */ 936 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.0.0' ); 937 return false; 938 } 939 940 $updated = update_metadata( 'blog', $site_id, $meta_key, $meta_value, $prev_value ); 941 942 // Bust site query cache. 943 if ( $updated ) { 944 wp_cache_set( 'last_changed', microtime(), 'sites' ); 945 } 946 947 return $updated; 907 return update_metadata( 'blog', $site_id, $meta_key, $meta_value, $prev_value ); 948 908 } 949 909 950 910 /** … … 956 916 * @return bool Whether the site meta key was deleted from the database. 957 917 */ 958 918 function delete_site_meta_by_key( $meta_key ) { 959 // Bail if site meta table is not installed. 960 if ( ! is_site_meta_supported() ) { 961 /* translators: %s: database table name */ 962 _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.0.0' ); 963 return false; 964 } 965 966 $deleted = delete_metadata( 'blog', null, $meta_key, '', true ); 967 968 // Bust site query cache. 969 if ( $deleted ) { 970 wp_cache_set( 'last_changed', microtime(), 'sites' ); 971 } 972 973 return $deleted; 919 return delete_metadata( 'blog', null, $meta_key, '', true ); 974 920 } 975 921 976 922 /** -
src/wp-includes/ms-default-filters.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
42 42 add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 ); 43 43 add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 ); 44 44 45 // Meta 46 add_filter( 'update_blog_metadata', '_disable_site_meta', 10, 1 ); 47 add_filter( 'add_blog_metadata', '_disable_site_meta', 10, 1 ); 48 add_filter( 'delete_blog_metadata', '_disable_site_meta', 10, 1 ); 49 add_filter( 'get_blog_metadata', '_disable_site_meta', 10, 1 ); 50 add_filter( 'update_blog_meta_cache', '_disable_site_meta', 10, 1 ); 51 45 52 // Register Nonce 46 53 add_action( 'signup_hidden_fields', 'signup_nonce_fields' ); 47 54 -
src/wp-includes/post.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1917 1917 $post_id = $the_post; 1918 1918 } 1919 1919 1920 $deleted = delete_metadata( 'post', $post_id, $meta_key, $meta_value ); 1921 if ( $deleted ) { 1922 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1923 } 1924 return $deleted; 1920 return delete_metadata( 'post', $post_id, $meta_key, $meta_value ); 1925 1921 } 1926 1922 1927 1923 /** … … 1966 1962 $post_id = $the_post; 1967 1963 } 1968 1964 1969 $updated = update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value ); 1970 if ( $updated ) { 1971 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1972 } 1973 return $updated; 1965 return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value ); 1974 1966 } 1975 1967 1976 1968 /** … … 1982 1974 * @return bool Whether the post meta key was deleted from the database. 1983 1975 */ 1984 1976 function delete_post_meta_by_key( $post_meta_key ) { 1985 $deleted = delete_metadata( 'post', null, $post_meta_key, '', true ); 1986 if ( $deleted ) { 1987 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1988 } 1989 return $deleted; 1977 return delete_metadata( 'post', null, $post_meta_key, '', true ); 1990 1978 } 1991 1979 1992 1980 /** -
src/wp-includes/taxonomy.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1180 1180 * False on failure. 1181 1181 */ 1182 1182 function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { 1183 // Bail if term meta table is not installed. 1184 if ( get_option( 'db_version' ) < 34370 ) { 1185 return false; 1186 } 1187 1188 if ( wp_term_is_shared( $term_id ) ) { 1189 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id ); 1190 } 1191 1192 $added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1193 1194 // Bust term query cache. 1195 if ( $added ) { 1196 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1197 } 1198 1199 return $added; 1183 return add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1200 1184 } 1201 1185 1202 1186 /** … … 1210 1194 * @return bool True on success, false on failure. 1211 1195 */ 1212 1196 function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { 1213 // Bail if term meta table is not installed. 1214 if ( get_option( 'db_version' ) < 34370 ) { 1215 return false; 1216 } 1217 1218 $deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1219 1220 // Bust term query cache. 1221 if ( $deleted ) { 1222 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1223 } 1224 1225 return $deleted; 1197 return delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1226 1198 } 1227 1199 1228 1200 /** … … 1237 1209 * @return mixed If `$single` is false, an array of metadata values. If `$single` is true, a single metadata value. 1238 1210 */ 1239 1211 function get_term_meta( $term_id, $key = '', $single = false ) { 1240 // Bail if term meta table is not installed.1241 if ( get_option( 'db_version' ) < 34370 ) {1242 return false;1243 }1244 1245 1212 return get_metadata( 'term', $term_id, $key, $single ); 1246 1213 } 1247 1214 … … 1262 1229 * WP_Error when term_id is ambiguous between taxonomies. False on failure. 1263 1230 */ 1264 1231 function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { 1265 // Bail if term meta table is not installed. 1266 if ( get_option( 'db_version' ) < 34370 ) { 1267 return false; 1268 } 1269 1270 if ( wp_term_is_shared( $term_id ) ) { 1271 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id ); 1272 } 1273 1274 $updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1275 1276 // Bust term query cache. 1277 if ( $updated ) { 1278 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1279 } 1280 1281 return $updated; 1232 return update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1282 1233 } 1283 1234 1284 1235 /** … … 1293 1244 * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success. 1294 1245 */ 1295 1246 function update_termmeta_cache( $term_ids ) { 1296 // Bail if term meta table is not installed.1297 if ( get_option( 'db_version' ) < 34370 ) {1298 return;1299 }1300 1301 1247 return update_meta_cache( 'term', $term_ids ); 1302 1248 } 1303 1249 … … 1313 1259 */ 1314 1260 function has_term_meta( $term_id ) { 1315 1261 // Bail if term meta table is not installed. 1316 if ( get_option( 'db_version' ) < 34370) {1262 if ( ! is_term_meta_supported() ) { 1317 1263 return false; 1318 1264 } 1319 1265 … … 1355 1301 return unregister_meta_key( 'term', $meta_key, $taxonomy ); 1356 1302 } 1357 1303 1304 /** 1305 * @param $value 1306 * 1307 * @return mixed 1308 */ 1309 function _disable_term_meta( $value ) { 1310 if ( ! is_term_meta_supported() ) { 1311 return false; 1312 } 1313 1314 return $value; 1315 } 1316 1317 /** 1318 * @param $value 1319 * @param $term_id 1320 * 1321 * @return mixed 1322 */ 1323 function _check_shared_term_meta( $value, $term_id ) { 1324 if ( wp_term_is_shared( $term_id ) ) { 1325 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id ); 1326 } 1327 1328 return $value; 1329 } 1330 1358 1331 /** 1359 1332 * Determines whether a term exists. 1360 1333 * -
src/wp-includes/user.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1357 1357 wp_cache_delete( $user->user_email, 'useremail' ); 1358 1358 wp_cache_delete( $user->user_nicename, 'userslugs' ); 1359 1359 1360 wp_cache_set( 'last_changed', microtime(), 'users' ); 1361 1360 1362 /** 1361 1363 * Fires immediately after the given user's cache is cleaned. 1362 1364 *