When calling wp_insert_category(), setting the second parameter to true lets us return a WP_Error. In this case, we don't, so 0 is returned in the case of a failure.
If a WP_Error or 0 value is returned, it will echo that it failed to import the category.
If we also have IMPORT_DEBUG set to true, it will try and fetch the error message from the returned value. This is fine, if we're returning a WP_Error, but in the case that it returns 0, it causes a fatal error.
Further to the above, in the Trac comments, we decided that a better approach than the above was to set the second argument of wp_insert_category() to true so that it returns a WP_Error object.
When calling
wp_insert_category()
, setting the second parameter to true lets us return aWP_Error
. In this case, we don't, so0
is returned in the case of a failure.If a
WP_Error
or0
value is returned, it will echo that it failed to import the category. If we also haveIMPORT_DEBUG
set to true, it will try and fetch the error message from the returned value. This is fine, if we're returning aWP_Error
, but in the case that it returns0
, it causes a fatal error.See: https://github.com/WordPress/wordpress-importer/blob/99462ec2d3390bc0de3bc5ffbe817f2160e5ef54/src/class-wp-import.php#L426-L438
I suggest that we add an additional check, to see if we have a
WP_Error
, before trying to render the error message: