• Resolved roelhugens

    (@roelhugens)


    When upgrading the project to php8 we get an error:
    Fatal error: Uncaught ValueError: Unknown format specifier “i” in /Users/roelhugens/Development/domains/flash/web/app/plugins/posts-to-posts/vendor/mustache/mustache/src/Mustache/Engine.php on line 606

    It can be fixed by changing this specifier from %i to %s
    Can this be committed in a tagged bugfix release?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter roelhugens

    (@roelhugens)

    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

    Thread Starter roelhugens

    (@roelhugens)

    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 3 years, 3 months ago by roelhugens.
    • This reply was modified 3 years, 3 months ago by roelhugens.
    Thread Starter roelhugens

    (@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.

    Plugin Author Stiofan

    (@stiofansisland)

    PHP 8 support is in v1.7

    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘PHP8.0 Fatal error’ is closed to new replies.