Ticket #21267: 21267.diff
File 21267.diff, 5.1 KB (added by , 10 years ago) |
---|
-
wp-includes/plugin.php
diff --git wp-includes/plugin.php wp-includes/plugin.php index c2aebf2..3df0181 100644
function _wp_call_all_hook($args) { 725 725 /** 726 726 * Build Unique ID for storage and retrieval. 727 727 * 728 * The old way to serialize the callback caused issues and this function is the729 * solution. It works by checking for objects and creating an a new property in730 * the class to keep track of the object and new objects of the same class that731 * need to be added.732 *733 * It also allows for the removal of actions and filters for objects after they734 * change class properties. It is possible to include the property $wp_filter_id735 * in your class and set it to "null" or a number to bypass the workaround.736 * However this will prevent you from adding new classes and any new classes737 * will overwrite the previous hook by the same class.738 *739 728 * Functions and static method callbacks are just returned as strings and 740 729 * shouldn't have any speed penalty. 741 730 * … … function _wp_call_all_hook($args) { 751 740 * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. 752 741 * @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a unique id. 753 742 */ 754 function _wp_filter_build_unique_id($tag, $function, $priority) { 755 global $wp_filter; 756 static $filter_id_count = 0; 757 758 if ( is_string($function) ) 743 function _wp_filter_build_unique_id( $tag, $function, $priority ) { 744 if ( is_string( $function ) ) 759 745 return $function; 760 746 761 if ( is_object($function) ) { 762 // Closures are currently implemented as objects 763 $function = array( $function, '' ); 764 } else { 765 $function = (array) $function; 766 } 747 if ( is_object( $function ) && 'Closure' === get_class( $function ) ) 748 return _wp_build_unique_closure_id( $function ); 767 749 768 if (is_object($function[0]) ) { 769 // Object Class Calling 770 if ( function_exists('spl_object_hash') ) { 771 return spl_object_hash($function[0]) . $function[1]; 772 } else { 773 $obj_idx = get_class($function[0]).$function[1]; 774 if ( !isset($function[0]->wp_filter_id) ) { 775 if ( false === $priority ) 776 return false; 777 $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count; 778 $function[0]->wp_filter_id = $filter_id_count; 779 ++$filter_id_count; 780 } else { 781 $obj_idx .= $function[0]->wp_filter_id; 782 } 750 $function = array_filter( (array) $function ); 783 751 784 return $obj_idx;785 }786 } else if ( is_string( $function[0]) ) {752 if ( is_object( $function[0] ) ) { 753 return spl_object_hash( $function[0] ) . '~' . get_class( $function[0] ) . '::' . $function[1]; 754 } else if ( is_string( $function[0] ) ) { 787 755 // Static Calling 788 return $function[0] . '::' . $function[1];756 return join( '::', $function ); 789 757 } 790 758 } 759 760 /** 761 * Build Unique ID for Closure 762 * 763 * @package WordPress 764 * @subpackage Plugin 765 * @since 3.7 766 * 767 * @param callback $function Used for creating unique id 768 * @return string Unique ID for usage as array key 769 */ 770 function _wp_build_unique_closure_id( $function ) { 771 ob_start(); 772 echo new ReflectionFunction( $function ); 773 $source = ob_get_clean(); 774 return md5( $source ); 775 } 776 /** 777 * Build Unique ID for list of callbacks 778 * 779 * @package WordPress 780 * @subpackage Plugin 781 * @since 3.7 782 * 783 * @param string $tag Name of filter 784 * @return string Unique ID representing hash of filter callback array keys (hashes) 785 */ 786 function wp_filter_callbacks_hash( $tag ) { 787 global $wp_filter; 788 789 if ( ! has_filter( $tag ) ) 790 return ''; 791 792 $hashes = array(); 793 794 foreach ( $wp_filter[$tag] as $priority ) 795 $hashes = array_merge( $hashes, array_keys( $priority ) ); 796 797 $hashes = array_map( '_dehash_filter_callback_object', $hashes ); 798 799 return md5( join( '', $hashes ) ); 800 } 801 802 /** 803 * Remove the spl_object_hash portion of the filter callback key 804 * This will allow persistence between requests 805 * 806 * @package WordPress 807 * @subpackage Plugin 808 * @since 3.7 809 * 810 * @param string $hash 811 * @return string 812 */ 813 function _dehash_filter_callback_object( $hash ) { 814 if ( strstr( $hash, '~' ) ) { 815 $bits = explode( '~', $hash, 2 ); 816 return $bits[1]; 817 } 818 return $hash; 819 } 820 No newline at end of file -
wp-includes/taxonomy.php
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php index 955369e..e094daf 100644
function get_terms($taxonomies, $args = '') { 1247 1247 } 1248 1248 1249 1249 // $args can be whatever, only use the args defined in defaults to compute the key 1250 $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';1251 $key = md5( serialize( compact( array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );1250 $filter_key = wp_filter_callbacks_hash( 'list_terms_exclusions' ); 1251 $key = md5( serialize( compact( array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $filter_key ); 1252 1252 $last_changed = wp_cache_get( 'last_changed', 'terms' ); 1253 1253 if ( ! $last_changed ) { 1254 1254 $last_changed = microtime();