Custom-Meta-Boxes icon indicating copy to clipboard operation
Custom-Meta-Boxes copied to clipboard

Fatal Error when saving certain Metabox Groups

Open mikeselander opened this issue 6 years ago • 1 comments

I haven't been able to trace this much deeper yet, but I get fatal errors on my local machine when a group is attempting to save without any data passed to it.

Stack trace:

[27-Mar-2018 20:32:53 UTC] PHP Fatal error:  Uncaught Error: Call to a member function set_values() on null in /chassis/wp-content/mu-plugins/custom-meta-boxes/fields/class-cmb-group-field.php:266
Stack trace:
#0 /chassis/wp-content/mu-plugins/custom-meta-boxes/fields/class-cmb-group-field.php(227): CMB_Group_Field->set_values(Array)
#1 /chassis/wp-content/mu-plugins/custom-meta-boxes/fields/class-cmb-field.php(397): CMB_Group_Field->parse_save_values()
#2 /chassis/wp-content/mu-plugins/custom-meta-boxes/class-cmb-meta-box.php(566): CMB_Field->save(25877, Array)
#3 /chassis/wp-content/mu-plugins/custom-meta-boxes/class-cmb-meta-box.php(592): CMB_Meta_Box->save(25877)
#4 /chassis/wordpress/wp-includes/class-wp-hook.php(300): CMB_Meta_Box->save_for_post(25877)
#5 /chassis/wordpress/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#6 /chassis/wordpress/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#7 /chassis/wordpress/wp-includes/post.php(3510): do_action('save_post', 25877, Object(WP_Post), true)
#8 /chassis/wordpress/wp-i in /chassis/wp-content/mu-plugins/custom-meta-boxes/fields/class-cmb-group-field.php on line 266

mikeselander avatar Mar 27 '18 20:03 mikeselander

I've tracked this down a bit more and certainly an edge case. I've identified 2 situations where this could occur.

  1. When there are multiple metabox groups with the same ID, but differing sets of fields (i.e. one of the groups has one more field than the others). Doesn't matter if they're assigned to different pages or not.
  2. When switching branches locally. Specifically, if you have a branch that has a new metabox group, you open an edit page, switch branches to a branch that doesn't have that group registered, and then hit save on the open edit page. (See, I told you this was edge case)

mikeselander avatar Mar 28 '18 16:03 mikeselander