impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
344 stars 191 forks source link

Unsupported operand types in PHP v8+ for receipt template #6711

Closed chepeftw closed 1 year ago

chepeftw commented 1 year ago

Description

I found that in the receipt template, in line 91, there is an issue between the operation and the operand types. It's trying to use the '+' operation on 2 strings. In older PHP versions (<= 7.0) this will work, in some v7 versions (>7.0, <8.0) it will throw a warning, but in newer versions (>= 8.0) this will fail. You can try this with a PHP sandbox tools.

Context

I found this issue while testing an offline donation. I could enter all my details, donate, in the backend the donation will show up, I will get the offline instructions email but in the donation page it will get stuck and never show the "thank you" view. After checking the network monitor (in Firefox), I found that a request returned 500 and after checking the logs I found this error: "NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + string in /var/www/html/wp-content/plugins/give/src/Views/Form/Templates/Sequoia/views/receipt.php:91". I did a manual fix and it's working now, but I think it should be solved in the plugin.

Solution

Change the "+=" to ".=" in the aforementioned file in line 91.

Versions

PHP 8.2 + Wordpress 6.1.1 (via Docker image wordpress:6.1.1-php8.2-fpm-alpine) GiveWP 2.25.0

kjohnson commented 1 year ago

Hey @chepeftw thanks for the report. Could you open a pull request for the change? I'd be happy to include your commit in the fix.

chepeftw commented 1 year ago

Hi @kjohnson, thanks for the reply. I already created the PR, although not sure of how to add the proper tag and not sure if I should create a unit test for this one. Let me know, thanks in advance.