[wp-trac] [WordPress Trac] #21267: Kill the serialization of $wp_filter in get_terms()
WordPress Trac
wp-trac at lists.automattic.com
Sun Aug 5 22:52:56 UTC 2012
#21267: Kill the serialization of $wp_filter in get_terms()
--------------------------+------------------
Reporter: nacin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.5
Component: Cache | Version:
Severity: normal | Resolution:
Keywords: needs-patch |
--------------------------+------------------
Comment (by wonderboymusic):
Here's how you can serialize a Closure instance, and by "serialize" I
really mean "create a unique identifier":
{{{
ob_start();
echo new ReflectionFunction( function ( $var1, $var2 ) {
return $var1 + $var2;
} );
$source = ob_get_clean();
echo md5( $source );
// makes md5 of this:
Closure [ <user> function {closure} ] {
@@ /Users/scott/Sites/wordpress-core/test.php 64 - 66
- Parameters [2] {
Parameter #0 [ <required> $var1 ]
Parameter #1 [ <required> $var2 ]
}
}
}}}
This works because ReflectionFunction implements the toString magic method
and is better than spl_object_hash which will refresh the hash on every
request.
http://www.php.net/manual/en/reflectionfunction.tostring.php
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21267#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list