Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#30960 closed defect (bug) (duplicate)

Error in taxonomy.php - serialization of closure not allwed

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



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. ""

Proposed solution:

The file taxonomy.php line 1673 contains


The error is fixed by using json_encode() instead of serialize()

Change History (2)

#1 @SergeyBiryukov
9 years ago

  • Component changed from General to Taxonomy

#2 @wonderboymusic
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #21267.

Note: See TracTickets for help on using tickets.