Support Forum
Support › MB Custom Post Type › PHP 8 Error after activating "MB Custom Post Types & Custom Taxonomies"Resolved
For some reason, I start receiving this error randomly throughout WordPress once I activate this plugin. One way I can trigger it is by simply trying to save Rank Math's Sitemap settings. It can be triggered outside of Rank Math though. I don't know what to do, but after deactivating every other plugin this seems to be the culprit.
Fatal error: Uncaught TypeError: Unsupported operand types: string & int in /sites/mydomain.com/html/wp-includes/class-wp-rewrite.php:1036 Stack trace: #0 /sites/mydomain.com/html/wp-includes/class-wp-rewrite.php(1405): WP_Rewrite->generate_rewrite_rules() #1 /sites/mydomain.com/html/wp-includes/class-wp-rewrite.php(1489): WP_Rewrite->rewrite_rules() #2 /sites/mydomain.com/html/wp-includes/class-wp-rewrite.php(1860): WP_Rewrite->wp_rewrite_rules() #3 /sites/mydomain.com/html/wp-includes/class-wp-hook.php(308): WP_Rewrite->flush_rules() #4 /sites/mydomain.com/html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #5 /sites/mydomain.com/html/wp-includes/plugin.php(517): WP_Hook->do_action() #6 /sites/mydomain.com/html/wp-settings.php(639): do_action() #7 /sites/mydomain.com/html/wp-config.php(117): require_once('...') #8 /sites/mydomain.com/html/wp-load.php(50): require_once('...') #9 /sites/mydomain.com/html/wp-admin/admin.php(34): require_once('...') #10 {main} thrown in /sites/mydomain.com/html/wp-includes/class-wp-rewrite.php on line 1036
My license is up for renewal and was leaning towards it, but this made me hesitate a bit. That, and I'm a bit peeved that there's a sale for 20% off but it doesn't apply to renewals and the "Developer" plan that I originally had is significantly more than Personal Ultimate bundle. So, honestly, seems like the renewal is kind of a sham.
Just as an FYI - this has broken accessing CPTs by the URL slug. So, I've had to disable this module and remove CPTs temporarily from the Navigation. CPTs is the primary use of Metabox for me. I've tried redownloading the plugin from the site and it was the same version I have installed (2.3.4), but the issue still occurs.
I enabled JUST the Meta Box and Meta Box AIO plugins, and not "MB Custom Post Types & Custom Taxonomies" plugin (that's left deactivated), but I have a post type with the slug "podcast" and "Prepended permalink structure" is unchecked. However, if I go to mydomain.com/podcast I get a 404 error. That's the same with all my other CPTs. One thing I can think of is that I recently switched hosting providers and they use NGINX as opposed to Apache. Would that play any role with this not working as expected?
Also, just curious, but it seems that I don't need "MB Custom Post Types & Custom Taxonomies" or "MB Relationships" as separate plugins if I have Meta Box and Meta Box AIO activated. Is that correct?
Ok, so I'm able to access a CPT such as https://ajtatumdigital.com/podcast/marketing/5-simple-activecampaign-tips/ but when I try to access https://ajtatumdigital.com/podcast/ I get a 404 error rather than the archives page. I have tried deactivating Permalink Manager Pro to see if that was a potential conflict, but it didn't make any difference. I am able to access https://ajtatumdigital.com/?post_type=podcast though and that should be the same page as https://ajtatumdigital.com/podcast/
There's definitely a conflict between Meta Box and Rank Math. As soon as Meta Box is enabled, whenever I try to save any settings in Rank Math I get the error I posted above. So, I had to disable all of Meta Box.
Hello AJ,
Thanks for your feedback.
Can you please create a staging site and share the credentials via this contact form?
https://metabox.io/contact/
I will take a closer look.
Sent
So, what's going on? I haven't heard anything and I have Rank Math looking into it as well and they're being much more responsive, despite them having a much less expensive plugin.
I've gotta say... I honestly like Meta Box, but your support is an atrocious. Seriously, for a plugin priced at your price point it should be better, especially when it's completely breaking a website. I've dealt with the poor support and learned that I need to just figure it out on my own, but if the reason why it's not working is because of the version and I'm not able to take advantage of the current pricing, I'm definitely going to weigh other options because this is honestly a joke. I'm sorry.
This is Rank Math's response. Can you confirm? Does the latest version work with PHP 8?
Hello,
Looking at the error it seems that the Metabox plugin still is not fully compatible with PHP8 and higher.
In this version of PHP, the mixed operands don’t throw a warning like they used to in PHP7.4 and as such plugin developers need to make sure this doesn’t happen with their plugins.
What is rather strange is the fact that this is happening on a default WordPress class so it seems that the code from Metabox is triggering the following to be converted to a string: EP_PAGES and EP_PERMALINK.
Those are called in a function that generates rewrite rules from a permalink structure so what you mention in the Metabox forums about the CPTs not being accessible as well seems to validate this information.
Unfortunately, this seems a case of the compatibility with PHP8 failing in one of the Metabox plugins and they would need to update their code to make sure the rewrite rules don’t trigger this error.
Don’t hesitate to get in touch if you have any other questions.
Hello AJ,
I'm sorry about the late reply due to the weekend. I've received your site credentials via the contact form but I cannot access the site to check the issue, screenshot https://monosnap.com/file/4dpmss0ONmTfZCttfNh7JPnv7vlNHb
Can you please create a staging site (not live site) with the issue replicated and send the credential again? I will inform the development team to check it as soon as possible.
If the issue relates to the plugin MB Custom Post Type when registering the custom post type, can you please generate the PHP code and add it to the file functions.php in the theme or child theme folder and check this issue again? This extension helps you to register the post types, taxonomies with UI instead of using the WordPress function register_post_type().
Refer to the documentation
https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code
https://developer.wordpress.org/reference/functions/register_post_type/
I have some country restrictions and whatnot. Had the same issue with Rank Math. I will remove the restrictions, but it may be easier if you VPN in. I'll send you a WireGuard configuration via contact form in case removing the firewall rules don't work.
Removed Firewall Restrictions but also created a WireGuard profile just in case and send it to you via contact form.
You pointed me in the right direction! For some reason, when I looked at the PHP code for Articles it looked much different than Podcast and other CPTs, so I removed properties that didn't exist in other CPTs and added properties that weren't in Articles. I updated it via the database as when I tried to change it from the editor, it wouldn't take effect. I don't know how but it had properties that were probably causing issues, most notably was this one:
'permalink_epmask' => EP_PERMALINK
Not sure how it got messed up, but all seems to be working now. I went into Rank Math and was successfully able to update the settings with Meta Box activated and no error occured.
Thanks!
Glad to hear it works.
I'm not sure why this happens on your site because the argument ep_mask
or permalink_epmask
is not supported in MB Custom Post Type. But I will inform the development team to take a closer look at this issue and see if there is something we can do from our side.