PHP 8 Compatibility for create_function function in Braintree SDK

Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Hotel Booking PHP 8 Compatibility for create_function function in Braintree SDK

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1553558
    Dave Clark
    Participant

    Hi folks, just mentioning this in case it is useful for anyone who is running PHP 8 and encountering similar issues like I was.

    Specifically if you are running PHP 8 and working with Braintree you may notice an issue related to code in the Braintree SDK.

    The code is used by the plugin but was not written by the folks at MotoPress so a quick fix can be to manually patch the code that is causing an issue for you.

    Assuming you have the plugin installed in WordPress, I noticed the file

    wordpress/wp-content/plugins/motopress-hotel-booking/vendors/braintree-sdk/lib/Braintree/Util.php

    had the following code

    $callback = create_function('$matches', 'return strtoupper($matches[1]);');

    which uses the create_function function and that function is deprecated in PHP 8.

    I replaced the code with the following PHP 8 compatible code

    $callback = function($matches) {
        return strtoupper($matches[1]);
    };

    If you come across any similar issues hopefully that gives you a bit of a steer.

    All the best folks.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.