permalinks – ‘Unsupported Operand Types’ error stemming from taxonomy re-writes with PHP 8.1

Question

I was getting a FATAL ERROR in WordPress, but only on the front end. I KNOW the error is within my plugin, but the stack trace returns info about WP Core files, and doesn’t identify where in my plugin the error is. (And the plugin is massive and complex, so process of elimination would take hours and hours.)

Fatal error: Uncaught TypeError: Unsupported operand types: string & int in /wordpress/wp-includes/class-wp-rewrite.php:1036 Stack trace: #0 /wordpress/wp-includes/class-wp-rewrite.php(1405): WP_Rewrite->generate_rewrite_rules('/programs/%basl...', 'EP_PERMALINK', true, true, false, true, true)

The key portion of this error is this:

'/programs/%basl...', EP_PERMALINK

Now, the only place where I could think of where my programs (a taxonomy) has any sort of re-write, is in the actual register_taxonomy() function.

Does anything in this code look as though it will cause an issue with PHP 8.1?

$taxonomy_rewrites   = array(
    'slug'                      => 'programs',
    'with_front'                => true,
    'hierarchical'              => false,
    'ep_mask'                   => 'EP_PERMALINK'
);

Does anyone know of anything different that we should be doing when creating taxonomies for WP/PHP 8.1?

(The exact same site is running in a production environment using PHP 7.4 and the issue has not presented itself. It’s just appeared in the development environment which I keep at PHP 8.1 specifically to try and catch issues like this.)

0
Tony Djukic 4 weeks 2023-01-10T18:07:57-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse