1 (edited by zetrader 2020-11-18 14:07)

Topic: Errors with php 8.0

Hello, when i try php 8.0 (beta) with my host (to check if PunBB could work in the future with php version after 7.4), forum list, forums with list of topics display well, but when i click on a topic or a post, it crashes, it doesn't display, only i have errors messages.
Clicking on a post i get this error :

Fatal error: Uncaught TypeError: mysqli_free_result(): Argument #1 ($result) must be of type mysqli_result, bool given in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php:246 Stack trace: #0 /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php(246): mysqli_free_result(true) #1 /homepages/3/d530603777/htdocs/zeforums.com/footer.php(130): DBLayer->close() #2 /homepages/3/d530603777/htdocs/zeforums.com/viewtopic.php(703): require('/homepages/3/d5...') #3 /homepages/3/d530603777/htdocs/zeforums.com/rewrite.php(93): require('/homepages/3/d5...') #4 {main} thrown in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php on line 246

On a topic, same type of error :

Fatal error: Uncaught TypeError: mysqli_free_result(): Argument #1 ($result) must be of type mysqli_result, bool given in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php:246 Stack trace: #0 /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php(246): mysqli_free_result(true) #1 /homepages/3/d530603777/htdocs/zeforums.com/footer.php(130): DBLayer->close() #2 /homepages/3/d530603777/htdocs/zeforums.com/viewtopic.php(703): require('/homepages/3/d5...') #3 /homepages/3/d530603777/htdocs/zeforums.com/rewrite.php(93): require('/homepages/3/d5...') #4 {main} thrown in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php on line 246

Line 246 in include/dblayer/mysqli.php says :

                @mysqli_free_result($this->query_result);

I use Visman punbb version, the last one, so it's the more updated version we can have of PunBB (compatible with php 7.4), that includes some fix for php 8 : https://punbb.informer.com/forums/post/158469/#p158469

Any way to fix this?
Thanks,

Pierre

Re: Errors with php 8.0

Please test

include/dblayer/mysqli.php and include/dblayer/mysqli_innodb.php

replace

    function free_result($query_id = false)
    {
        return ($query_id) ? @mysqli_free_result($query_id) : false;
    }

to

    function free_result($query_id = false)
    {
        if ($query_id) {
            $result = @mysqli_free_result($query_id);

            if ($query_id === $this->query_result) {
                $this->query_result = null;
            }

            return $result;
        } else {
            return false;
        }
    }
Parserus, UserAgentAnalyzer.
I speak only Russian  :P

3 (edited by zetrader 2020-11-18 15:43)

Re: Errors with php 8.0

I've just tried (changed and uploaded the 2 files) that with php 7.4, it works, switching to php 8.0 the error change a little bit when i go to topics or posts, not the same line :

Fatal error: Uncaught TypeError: mysqli_free_result(): Argument #1 ($result) must be of type mysqli_result, bool given in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php:256 Stack trace: #0 /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php(256): mysqli_free_result(true) #1 /homepages/3/d530603777/htdocs/zeforums.com/footer.php(130): DBLayer->close() #2 /homepages/3/d530603777/htdocs/zeforums.com/viewtopic.php(703): require('/homepages/3/d5...') #3 /homepages/3/d530603777/htdocs/zeforums.com/rewrite.php(93): require('/homepages/3/d5...') #4 {main} thrown in /homepages/3/d530603777/htdocs/zeforums.com/include/dblayer/mysqli.php on line 256

Edit : as it doesn't work, i came back to original files and php 7.4

Re: Errors with php 8.0

Ok, I'll test it with mysqli. Right now I have sqlite3 on my local machine enabled on the test forum.

Parserus, UserAgentAnalyzer.
I speak only Russian  :P

Re: Errors with php 8.0

https://github.com/MioVisman/punbb/comm … e74f866ab3

Please test for 7.4 and 8.0.

Parserus, UserAgentAnalyzer.
I speak only Russian  :P

6 (edited by zetrader 2020-11-18 17:30)

Re: Errors with php 8.0

I made those changes, it works for php 7.4 and 8.0 (for mysqli, i made change for sqlite3 file too, but i don't use it, so i don't know), topics and posts display correctly now, Visman you're the boss smile

EDIT : checking post as guest or member, it works too, but i try to upload an image with Pan Uploader 0.4.9 ((the last version i know), it says "When you upload a file an error has occurred." but that's another topic, i'll make report in the topic of Pan Uploader as this extension works fine with php 7.4

Thanks Visman smile