Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#30960 closed defect (bug) (duplicate)

Error in taxonomy.php - serialization of closure not allwed

Reported by: stracker.phil Owned by:
Priority: normal Milestone:
Component: Taxonomy Version: 4.1
Severity: normal Keywords:
Cc: Focuses:

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)

#1 @SergeyBiryukov
12 years ago

  • Component General → Taxonomy

#2 @wonderboymusic
12 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #21267.

Note: See TracTickets for help on using tickets.