Opened 9 years ago
Closed 9 years ago
#30960 closed defect (bug) (duplicate)
Error in taxonomy.php - serialization of closure not allwed
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
Error:
Fatal Error: Uncaught Exception 'exception' With Message 'serialization Of 'closure' Is Not Allowed' In Wp-includes/taxonomy.php On Line 1673
I could not create a code snippet to reproduce the error, however on my website it happens when these 3 factors are combined:
1) A custom Post-Type is defined that uses a closure, i.e. this is my code:
$type = 'posttype'; $data = array( ... ); $data['register_meta_box_cb'] = function( $post ) use ( $type ) { do_action( 'my-metaboxes-' . $type, $post ); }; register_post_type( $type, $data );
2) The action "pre_get_posts" calls the function "get_categories()", i.e.:
add_action( 'pre_get_posts', 'check_type' ); public function check_type() { $items = get_categories( 'get=all' ); }
3) When opening the Archive page of the custom post type the above error is displayed, i.e. "example.org/posttype/"
Proposed solution:
The file taxonomy.php line 1673 contains
serialize($GLOBALS['wp_filter']['list_terms_exclusions'])
The error is fixed by using json_encode()
instead of serialize()
Change History (2)
Note: See
TracTickets for help on using
tickets.
Duplicate of #21267.