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;
        }
    }
ForkBB
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.

ForkBB
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.

ForkBB
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

Re: Errors with php 8.0

38. Fix search (Uncaught Error: mysqli_result object is already closed in ...) for PHP 8
https://github.com/MioVisman/punbb/comm … f11550a9ef

ForkBB
I speak only Russian  :P

Re: Errors with php 8.0

Hi, with a fresh new install of https://github.com/MioVisman/punbb
I have this error with php 8 :

Warning: Undefined variable $main_tpl in /zeforums.com/punbb21/footer.php(44) : eval()'d code on line 10

Back to php 7.4 the error disappears, going back to php 8, the error is back again.

Re: Errors with php 8.0

You have an error in one of the installed extensions.

footer.php(44) : eval()'d code on line 10

Line 44 calls the hook named ft_about_end

($hook = get_hook('ft_about_end')) ? eval($hook) : null;
ForkBB
I speak only Russian  :P

10

Re: Errors with php 8.0

Additional Information:
There is no $main_tpl variable in punbb, there is a $tpl_main variable. Inform the author of the extension about this wink

ForkBB
I speak only Russian  :P

11 (edited by zetrader 2021-05-15 15:10)

Re: Errors with php 8.0

You're right, i've installed with a few extensions, i found the guilty one : "Pan Framework 0.1.8" (when i disable that one, the message disappears, if i activate the message appears).
It's that extension :
https://punbb.info/t-565.html

*Edit* the error has already been mentionned but not fixed, the error is explained here by belelectroteam :
https://punbb.info/post10552.html#p10552

"There is a bug in this extension (version 0.1.8)! Hooks are installed in the manifest.xml
file at the end (3 pieces). So the third hook has the variable main_tpl , but it should be the other way around - tpl_main . There, in the third hook, you need to correct the name of the variable in two places. Here's this piece of code (with a bug fixed):

<hook id="ft_about_end" priority="10"><![CDATA[if(!defined('COPY_PUNBB_INFO')){$tpl_main=str_replace('<a href="http://punbb.informer.com/">PunBB</a>','<a href="https://punbb.info">PunBB</a>',$tpl_main);define('COPY_PUNBB_INFO', 1);}]]></hook>

Probably, we need to make version 0.1.9.

And you will have a clean error log!"