Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Hotel Booking PHP 8 Compatibility for create_function function in Braintree SDK
- This topic has 0 replies, 1 voice, and was last updated 11 months, 2 weeks ago by Dave Clark.
- AuthorPosts
- January 8, 2024 at 2:14 am #1553558Dave ClarkParticipant
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.
- AuthorPosts
- You must be logged in to reply to this topic.