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

Deprecated warnings all over site when using PHP 8.1 #934

Closed mikewcaldwell closed 1 year ago

mikewcaldwell commented 2 years ago

I recently tried to set up a q2a site using php 8.1, and first of all I was unable to run the install wizard from the browser, so I had to manually do that through the code.

After that I was able to load the site, but it is covered with warnings (see screenshot).

スクリーンショット 2022-01-18 午後1 32 47

It seems that from php 8.1 passing in null to strlen is deprecated, and eventually will throw a TypeError in later releases. see: https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation

I'm assuming there are other functions where similar warnings occur as well.

I have since reverted to php 8.0 and things seem to be working fine but I imagine this will be an issue going forward.

asterbini commented 2 years ago

I have been able to convert the Q2A code to PHP 8.1 by using the rector project (https://github.com/rectorphp/rector). Moreover, GD images are no more resources in 8.1 but objects and I had to change util/image.php a little to show avatars. (now that I look for is_resource in the rest of the code I see that I must change also app/upload.php and app/blobs.php)

svivian commented 1 year ago

This has been resolved in Q2A 1.8.7. Thanks!