Jetpack: Core Image Migration: post type jetpack_migration is not registered

Created on 8 Jul 2017  路  2Comments  路  Source: Automattic/jetpack

Steps to reproduce the issue

Turn on DEBUG_LOG (define true).

Create a post.

Save as draft.

What I expected

No warnings or notices.

What happened instead

PHP notices about post types not being registered.

PHP Notice: map_meta_cap was called incorrectly. The post type jetpack_migration is not registered, so it may no
t be reliable to check the capability "edit_post" against a post of that type. Please see Debugg
ing in WordPress
for more information. (This message was added in version 4.4.0.) in /var/www/hmlive/wp-includes/functions.php on line 4139

Triggered by 'widgets_init' action call via
add_action( 'widgets_init', 'jetpack_migrate_image_widget' );
in image-widget.php.

This new module was added in JetPack 4.9 according to the phpDoc
header and I did recently upgrade the JP on this site from < 4.9 to
5.1.

The problem , at least from what I can tell, is the
'jetpack_migration' post type is never registered. I don't see how
this piece of code could have ever worked as intended; at least not in
the production form.

Maybe a branch was no merged properly before
release?

The "nice" way to manage this would be to ensure the jetpack_migration post type is registered BEFORE calling wp_insert_post() and maybe do something nicer than generate a notice/warning.

Since this function does not appear that it will actually do anything when jetpack_store_legacy_image_widget_options() is called some investigation may want to occur as to why this seems to be called on every post save if a site has JetPack 4.9+ installed. Seems like a lot of extra overhead. Maybe it is the wonderful theme I am using on the HereMusic.Live site. I've not tested this on the half-dozen other sites I am running JetPack on.

If you need more info please let me know.

Extra Sidebar Widgets [Pri] Normal [Type] Bug

Most helpful comment

Hi, sorry to know that you're having this issue. For any other checking this issue, I've reproduced this after deleting what indicated that my widget migration had been performed with:
wp jetpack options delete image_widget_migration

The wp_insert_post call actually works without needing a CPT to be registered before. However, in your and my case it seems other plugins were performing calls such that map_meta_cap was called. I've opened this PR that fixes this issue.

The easiest way to temporarily patch this is to set WP_DEBUG to false, however, if you want to have it turned on, so here are some alternatives:

  • you can solve this if you're using WP CLI with
    wp jetpack options update image_widget_migration true

  • if you're not using WP CLI, you can edit wp-content/plugins/jetpack/jetpack.php and paste this at the end:
    Jetpack_Options::update_option( 'image_widget_migration', true );
    and load Jetpack settings screen. Then delete the line since it's no longer needed.

All 2 comments

I have just started encountering this issue on one of my sites that uses JetPack today. Is there any chance you have found a fix to this problem? I'm now unable to save drafts of my posts.

Hi, sorry to know that you're having this issue. For any other checking this issue, I've reproduced this after deleting what indicated that my widget migration had been performed with:
wp jetpack options delete image_widget_migration

The wp_insert_post call actually works without needing a CPT to be registered before. However, in your and my case it seems other plugins were performing calls such that map_meta_cap was called. I've opened this PR that fixes this issue.

The easiest way to temporarily patch this is to set WP_DEBUG to false, however, if you want to have it turned on, so here are some alternatives:

  • you can solve this if you're using WP CLI with
    wp jetpack options update image_widget_migration true

  • if you're not using WP CLI, you can edit wp-content/plugins/jetpack/jetpack.php and paste this at the end:
    Jetpack_Options::update_option( 'image_widget_migration', true );
    and load Jetpack settings screen. Then delete the line since it's no longer needed.

Was this page helpful?
0 / 5 - 0 ratings