Tutorial: How to fix the Smilies Categories extension

  • Computers and technology: programming, hardware, software, gadgets, cyber security, ...
  • phpBB tutorials

Post Reply
User avatar
Selene310187
Site Admin
Joined: Fri Oct 07, 2022 8:34 pm
Contact:

Tutorial: How to fix the Smilies Categories extension

Post by Selene310187 »

I recently installed the Smilies Categories* extension for phpBB created by Sylver35 from the French phpBB forum Breizh Code. Before I put the extension on the live forum of Modding on the Spectrum, I tested it on my test forum on my local machine.

(I recommend everyone testing stuff before you make changes to your live forum in case something goes wrong :sn-37:)

* The extension lets you place the smilies of the forum into categories which can be accessed via the "View more smilies" link above and below the Smilies section of the posting editor. The purpose of this extension is to keep the Smilies section organized when more and more smilies are added to the forum.


As soon as I try to access the "Configuration of categories" menu in the Admin Control Panel (the menu can be found under posting > messages), I got following error message:

Code: Select all

Fatal error: Uncaught TypeError: mysqli_data_seek(): Argument #2 ($offset) must be of type int, mysqli_result given in C:\xampp\htdocs\modding-on-the-spectrum.com\phpbb\db\driver\mysqli.php:288 Stack trace: #0 C:\xampp\htdocs\modding-on-the-spectrum.com\phpbb\db\driver\mysqli.php(288): mysqli_data_seek(Object(mysqli_result), Object(mysqli_result)) #1 C:\xampp\htdocs\modding-on-the-spectrum.com\phpbb\db\driver\driver.php(381): phpbb\db\driver\mysqli->sql_rowseek(Object(mysqli_result), Object(mysqli_result)) #2 C:\xampp\htdocs\modding-on-the-spectrum.com\phpbb\db\driver\factory.php(297): phpbb\db\driver\driver->sql_fetchfield('maxi', Object(mysqli_result), Object(mysqli_result)) #3 C:\xampp\htdocs\modding-on-the-spectrum.com\ext\sylver35\smiliescat\core\category.php(153): phpbb\db\driver\factory->sql_fetchfield('maxi', Object(mysqli_result)) #4 C:\xampp\htdocs\modding-on-the-spectrum.com\ext\sylver35\smiliescat\core\category.php(461): sylver35\smiliescat\core\category->get_max_order() #5 C:\xampp\htdocs\modding-on-the-spectrum.com\ext\sylver35\smiliescat\controller\admin_controller.php(194): sylver35\smiliescat\core\category->adm_list_cat('./../adm/index....') #6 C:\xampp\htdocs\modding-on-the-spectrum.com\ext\sylver35\smiliescat\acp\main_module.php(53): sylver35\smiliescat\controller\admin_controller->acp_categories_config() #7 C:\xampp\htdocs\modding-on-the-spectrum.com\includes\functions_module.php(676): sylver35\smiliescat\acp\main_module->main('\\sylver35\\smili...', 'config') #8 C:\xampp\htdocs\modding-on-the-spectrum.com\adm\index.php(81): p_master->load_active() #9 {main} thrown in C:\xampp\htdocs\modding-on-the-spectrum.com\phpbb\db\driver\mysqli.php on line 288
I got a similar error message when I tried to change the name of a category.

Additional information: The forum uses phpBB 3.3.9 and runs on PHP 8.1 as I'm writing this.


I figured out that it has something to do with the sql_fetchfield function having too many arguments (I found the final hint in this post).

So I checked the lines of code that contain the sql_fetchfield functions in the category.php (ext\sylver35\smiliescat\core). The sql_fetchfield functions in these line have too many arguments: lines 153, 165 and 390.



Find:

Code: Select all

$max = $this->db->sql_fetchfield('maxi', $result);
(line 153)


Replace with

Code: Select all

$max = $this->db->sql_fetchfield('maxi');



Find:

Code: Select all

$id_max = (int) $this->db->sql_fetchfield('id_max', $result);
(line 165)


Replace with

Code: Select all

$id_max = (int) $this->db->sql_fetchfield('id_max');



Find:

Code: Select all

$total = (int) $this->db->sql_fetchfield('total', $result);
(line 390)


Replace with

Code: Select all

$total = (int) $this->db->sql_fetchfield('total');

Tags:
User avatar
Altbert
Moderator
Joined: Tue Nov 01, 2022 10:58 pm
Location: Netherlands
Contact:

Re: How to fix the Smilies Categories extension

Post by Altbert »

At least you know the error is caused by the mysqli_data_seek function, argument #2. This argument expects an integer, either 0 or the number of fields -1.
I haven't look at the actual code, but fields in mysql(i) are zero based, and so the integer number of the last field is always (number of fields - 1). Could that be the problem?
Bis vincit, qui se vincit in victoria - He conquers twice who conquers himself in victory (Publius Syrus)
User avatar
Selene310187
Site Admin
Joined: Fri Oct 07, 2022 8:34 pm
Contact:

Re: Tutorial: How to fix the Smilies Categories extension

Post by Selene310187 »

I just contacted sylver35, the author of the extension, via phpbb.com* and informed him about the bug and my solution.

* I especially created an account there today in order to send the message to the author


Edit: I added the word "tutorial" to the title of the thread to avoid (further) confusion :sn-37:.
User avatar
Altbert
Moderator
Joined: Tue Nov 01, 2022 10:58 pm
Location: Netherlands
Contact:

Re: Tutorial: How to fix the Smilies Categories extension

Post by Altbert »

Yes, the mysqli_fetchfield should only have one argument which is the result of the mysqli_data_seek function.

Hope you get some reaction of sylver35!
Bis vincit, qui se vincit in victoria - He conquers twice who conquers himself in victory (Publius Syrus)
User avatar
Selene310187
Site Admin
Joined: Fri Oct 07, 2022 8:34 pm
Contact:

Re: Tutorial: How to fix the Smilies Categories extension

Post by Selene310187 »

Altbert wrote: Wed Dec 07, 2022 10:17 pmHope you get some reaction of sylver35!
At the moment, I unable to check my messages on phpbb.com because I have very limited access to the forum when I'm logging in due to unknown reasons (can't the see content of the forum as well while being logged in). This happened after about one hour after my registration on their site.

I already contacted the administrators via the contact form asking them what did happen. I haven't got an answer yet.
Post Reply

Return to “Technical Room”