q2a / question2answer

Question2Answer is a free and open source platform for Q&A sites, running on PHP/MySQL.
http://www.question2answer.org/
GNU General Public License v3.0
1.63k stars 629 forks source link

PHP 8.0 Fatal Error #888

Closed QROkes closed 3 years ago

QROkes commented 3 years ago

Doing some quick testing using PHP 8.0, I found a fatal error when visiting the "Register" page:

2021/03/28 17:05:17 [error] 36104#36104: *73759 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /var/www/example.com/htdocs/support/qa-include/app/captcha.php:98 Stack trace: #0 /var/www/example.com/htdocs/support/qa-include/pages/register.php(219): qa_set_up_captcha_field() #1 /var/www/example.com/htdocs/support/qa-include/app/page.php(183): require('...') #2 /var/www/example.com/htdocs/support/qa-include/qa-page.php(47): qa_get_request_content() #3 /var/www/example.com/htdocs/support/qa-include/qa-index.php(188): require('...') #4 /var/www/example.com/htdocs/support/index.php(27): require('...') #5 {main} thrown in /var/www/example.com/htdocs/support/qa-include/app/captcha.php on line 98" while reading response header from upstream, client: 2805:1015:f:270e:c1e9:8a26:be3f:71bd, server: example.com, request: "GET /support/register?to= HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "example.com", referrer: "https://example.com/support/"

Would be nice if a warning message is added to the official installation page, (PHP 5.2 or later is recommended). Normally, I use 7.4 for Q2A and everything runs just fine!

svivian commented 3 years ago

Thanks for the bug report. This should be fixed by afb884b75b0db343cd32f5885132049e115dcc3d

Will be part of the upcoming v1.8.6 but it's a simple fix you can add to your site in the meantime.

QROkes commented 3 years ago

Hi @svivian

The same FATAL error appeared now in forgot.php

2021/04/29 18:27:26 [error] 18281#18281: *304592 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /var/www/example.com/htdocs/support/qa-include/app/captcha.php:98
Stack trace:
#0 /var/www/example.com/htdocs/support/qa-include/pages/forgot.php(113): qa_set_up_captcha_field()
#1 /var/www/example.com/htdocs/support/qa-include/app/page.php(183): require('...')
#2 /var/www/example.com/htdocs/support/qa-include/qa-page.php(47): qa_get_request_content()
#3 /var/www/example.com/htdocs/support/qa-include/qa-index.php(188): require('...')
#4 /var/www/example.com/htdocs/support/index.php(27): require('...')
#5 {main}
  thrown in /var/www/example.com/htdocs/support/qa-include/app/captcha.php on line 98" while reading response header from upstream, client: 2907:1026:f:5289:3c9e:b092:de29:7013, server: example.com, request: "GET /support/forgot HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "example.com", referrer: "https://example.com/support/login?to="
pupi1985 commented 3 years ago

@QROkes Can you try this branch and report back if this fixed it or not?

Note there are may pieces of the code that might generate that issue.

QROkes commented 3 years ago

Hi @pupi1985 , I installed your branch on a production site, at first sight everything seems fine, but I will keep an eye on server logs these days.

QROkes commented 3 years ago

Just for the record, after a week of testing this branch, seems like it's safe to use Q2A with PHP 8 now, no errors or warning messages in server logs. The only critical issue is #895 which seems to be related to PHP 8.

Thanks!