The above “solution” is of course not what it fixes, since it needs to be an integer value. I’m not sure what the exact specifier it should be (see https://www.php.net/manual/en/function.sprintf.php).
My guess it needs to be “u”? Hope you can give an update
Plugin Author
Stiofan
(@stiofansisland)
Hello,
How do i replicate this fatal error? ( i have tried )
Thanks,
Stiofan
Hi Stiofan,
We used this plugin before and had no issues.
For a new project we upgraded PHP from 7.4 to 8 and this issue popped up.
When we want to make the connection between two custom posttypes like in the code below, the error shows us that the “i” format specifier is unknown.
p2p_register_connection_type([
'name' => "posttype1_to_posttype2",
'from' => 'posttype1',
'to' => 'posttype2',
'cardinality' => 'many-to-many',
'reciprocal' => true,
'sortable' => 'any',
'admin_column' => 'any',
'admin_dropdown' => 'any',
'can_create_post' => false,
'admin_box' => [
'show' => 'any',
'context' => 'advanced',
],
]);
This issue is triggered in the mustache plugin that is used by p2p
Let me know if you need more info, I can make it work by changing the identifier in the plugin. But I’m not 100% sure if it is the right solution.
Thanks in advance,
Roel
-
This reply was modified 4 years, 9 months ago by
roelhugens.
-
This reply was modified 4 years, 9 months ago by
roelhugens.
Some extra info about where the issue is:
posts-to-posts/vendor/mustache/mustache/src/Mustache/Engine.php in the function getTemplateClassName.
There is entity_flags:%i set as integer (%i) but this format specifier is unknown for the sprintf function. So I changed this to %u (unsigned integer representation of a positive integer)
I have created a pull request on your repo @stiofansisland. It fixes the fatal error on PHP 8.
Still works on previous versions of PHP as well.
https://github.com/AyeCode/wp-posts-to-posts/pull/2
Hope you consider merging it. π
Same problem fatal error in the back end editing a Woo Product (that uses Posts2posts) – fixed it locally by changing the sprintf specifier. An official plug in update would be appreciated – thx.
Still have a warning
Deprecated: Required parameter $nonce follows optional parameter $formdata in /wp-content/plugins/posts-to-posts/vendor/scribu/scb-framework/Forms.php on line 65
Deprecated: Required parameter $args follows optional parameter $file in /wp-content/plugins/posts-to-posts/vendor/scribu/scb-framework/Cron.php on line 24
β― php -v
PHP 8.0.19 (cli) (built: May 12 2022 02:41:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.19, Copyright (c) Zend Technologies
Thanks @stiofansisland for the update.