Hello, I'm using this extension to add, among other things, the "New Topics" and "Active Topics" buttons to my forum 3.3.15,PHP 8.4.17, but I was getting an error with the "Active Topics" link.
Here is the error:
Code: Select all
SQL ERROR [ mysqli ] Incorrect integer value: '' for column 'buttonindex_fav' at row 1 [1366] SQL UPDATE phpbb_buttonindex SET buttonindex_text = 'Sujets Actifs', buttonindex = 'search.php?search_id=active_topics', buttonindex_fav = '' WHERE buttonindex_id = 3 BACKTRACE FILE: (not given by php) LINE: (not given by php) CALL: msg_handler() FILE: [ROOT]/phpbb/db/driver/driver.php LINE: 1031 CALL: trigger_error() FILE: [ROOT]/phpbb/db/driver/mysqli.php LINE: 216 CALL: phpbb\db\driver\driver->sql_error() FILE: [ROOT]/phpbb/db/driver/factory.php LINE: 353 CALL: phpbb\db\driver\mysqli->sql_query() FILE: [ROOT]/ext/dmzx/buttonindex/controller/admin_controller.php LINE: 196 CALL: phpbb\db\driver\factory->sql_query() FILE: [ROOT]/ext/dmzx/buttonindex/acp/acp_buttonindex_module.php LINE: 39 CALL: dmzx\buttonindex\controller\admin_controller->display_options() FILE: [ROOT]/includes/functions_module.php LINE: 684 CALL: dmzx\buttonindex\acp\acp_buttonindex_module->main() FILE: [ROOT]/adm/index.php LINE: 81 CALL: p_master->load_active()
Being a complete novice in this area, I asked an AI for help, and here is the solution it provided, along with this comment:
diff --git a/ext/dmzx/buttonindex/controller/admin_controller.php b/ext/dmzx/buttonindex/controller/admin_controller.php
index 3f4c2a1..9b7e6d4 100644
--- a/ext/dmzx/buttonindex/controller/admin_controller.php
+++ b/ext/dmzx/buttonindex/controller/admin_controller.php
@@ -183,7 +183,7 @@ class admin_controller
if (empty($errors))
{
$name = $this->db->sql_escape($this->request->variable('name', '', true));
$url = $this->db->sql_escape($this->request->variable('url', ''));
- $fav = $this->db->sql_escape($this->request->variable('fav', ''));
+ $fav = (int) $this->request->variable('fav', 0);
if ($name && $url && !$edit_id)
{
When adding or modifying a button, if the "favorite" option is not checked,
the extension sends an empty value ('') to the buttonindex_fav field, which is of type INT.
In a strict MySQL environment, this causes the error:
SQL ERROR 1366 – Incorrect integer value.
The attached fix forces the value to 0 or 1 via a cast (int),
which permanently resolves the issue and adheres to phpBB best practices.
This has indeed fixed my problem.
I'm posting this solely to share my experience and perhaps inspire you to make your own fix for this extension, which I appreciate.
Thank you.