Hi @locke85,
I’ve checked the plugin and couldn’t find any usage of the map_meta_cap() function. It can be a conflict with another plugin or the theme. Have you tried temporarily switching to a default theme and disabling other plugins one by one? This might help to find out where the conflict is coming from.
Thread Starter
Jan
(@locke85)
Hi @zahardoc,
I’ve thoroughly reviewed my own theme and functions.php. None of my custom code touches the podcast post type directly, except for the standard filter ssp_register_post_type_args to add 'revisions' support — which is documented and used as intended.
From the backtrace, the error is triggered during a wp_ajax_heartbeat request inside the post editor for a podcast post. At that point, current_user_can('edit_post', $post_id) triggers map_meta_cap(), but the podcast post type is not yet registered — resulting in the error and backend freeze.
My suspicion is that the post type registration (register_post_type('podcast', …)) may not fire early enough for AJAX calls. Could you verify if the registration is hooked into init or runs earlier?
Thanks again!
@locke85
Thank you for the additional details. I looked into this more deeply, and it appears to be a bug in WordPress core. The issue originates from the wp_refresh_post_lock() function, which is triggered by the heartbeat_received action before the init action runs:
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
Specifically, the check current_user_can( 'edit_post', $post_id ) is located in wp-admin/includes/misc.php on line 1197 ( as of WordPress 6.8.1 ).
So, I believe the bug would affect all custom post types that are registered during the init action — not just the podcast post type.
Thread Starter
Jan
(@locke85)
Thank for getting back @zahardoc
Meanwhile I added them temp fix on my site:
add_action('after_setup_theme', function () {
if (!post_type_exists('podcast')) {
register_post_type('podcast', [
'label' => 'Podcast (early fallback)',
'public' => false,
'show_ui' => false,
'supports' => ['title'],
]);
}
}, 5);
…and created this ticket @wp_trac.
Best regards,
Jan
@locke85
Great, thanks for the code and creating a ticket in WP.
Thread Starter
Jan
(@locke85)
Hi @zahardoc
Meanwhile, this went back and forth.
To fix the issue on my site I added this php temporarily:
// SSP - Temp to debug page freeze issue
add_action('after_setup_theme', function () {
if (!post_type_exists('podcast')) {
register_post_type('podcast', [
'label' => 'Podcast (early fallback)',
'public' => false,
'show_ui' => false,
'supports' => ['title'],
]);
}
}, 5);
add_action('init', function () {
add_filter('map_meta_cap', 'debug_map_meta_cap', 10, 4);
});
// Fix: Force SSP podcast CPT registration to priority 10 instead of 11
add_action('after_setup_theme', function () {
// Make sure SSP class exists before manipulating
if (class_exists('SSP_Post_Type')) {
// Remove SSP registration at 11
remove_action('init', [ 'SSP_Post_Type', 'register_post_type' ], 11);
// Add SSP registration at 10
add_action('init', [ 'SSP_Post_Type', 'register_post_type' ], 10);
}
}, 9);
function debug_map_meta_cap($caps, $cap, $user_id, $args) {
if (isset($args[0]) && is_numeric($args[0])) {
$post = get_post($args[0]);
if ($post && $post->post_type === 'podcast' && !post_type_exists('podcast')) {
error_log('⚠️ map_meta_cap called for unregistered post type "podcast"');
error_log('Capability: ' . $cap);
error_log('User ID: ' . $user_id);
error_log('Post ID: ' . $args[0]);
// vollständiger Stacktrace
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20);
$trace = ob_get_clean();
error_log("Backtrace:\n" . $trace);
}
}
return $caps;
}
Is there anything else that you can suggest based on the testing done by mindctrl ?
Any advice is much appreciated.
Best,
Jan