[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] Use filename hash as secdb primary key to avoid long path collisions

"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a1244f3dbccf_389bf0ba475e6@gitlab-sidekiq-low-urgency-cpu-bound-v2-d7f87744c-b6gpt.mail>

ushindi bienvenu pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
30f7fd63 by ushindi bienvenu at 2026-05-24T02:22:54+02:00
[FIX] Use filename hash as secdb primary key to avoid long path collisions

- - - - -


3 changed files:

- db/tiki-secdb_27.6_mysql.sql
- db/tiki.sql
- doc/devtools/release.php


Changes:

=====================================
db/tiki-secdb_27.6_mysql.sql
=====================================
@@ -1,6 +1,6 @@
 start transaction;
 DELETE FROM `tiki_secdb`;
-ALTER TABLE `tiki_secdb` DROP PRIMARY KEY,  ADD PRIMARY KEY (`filename_hash`, `tiki_version`(20));
+ALTER TABLE `tiki_secdb` DROP PRIMARY KEY, ADD PRIMARY KEY (`filename_hash`, `tiki_version`(20));
 
 INSERT INTO `tiki_secdb` (`filename`, `filename_hash`, `md5_value`, `tiki_version`) VALUES 
 ('./.phpstorm.meta.php', '6283717f3d9f91228cdbd0dcf5fd7b56', 'c94a2803140338162737442f39b534bf', '27.6'),


=====================================
db/tiki.sql
=====================================
@@ -2212,10 +2212,11 @@ DROP TABLE IF EXISTS `tiki_secdb`;
 CREATE TABLE tiki_secdb(
   `md5_value` varchar(32) NOT NULL,
   `filename` varchar(250) NOT NULL,
+  `filename_hash` char(32) NOT NULL,
   `tiki_version` varchar(60) NOT NULL,
   `severity` int(4) NOT NULL default '0',
-  PRIMARY KEY (`filename`(186),`tiki_version`(5)),
-  KEY `sdb_fn` (filename(191))
+  PRIMARY KEY (`filename_hash`, `tiki_version`(20)),
+  KEY `sdb_fn` (`filename`(191))
 ) ENGINE=MyISAM;
 
 DROP TABLE IF EXISTS `tiki_semaphores`;


=====================================
doc/devtools/release.php
=====================================
@@ -304,9 +304,9 @@ function updateSecdb($version)
         // This index was originally created with a size limit that would raise an error on some versions,
         // notably on 18.0. Since this file is executed before any patch in installer/schema, the fix had to
         // be done here. It's a quick operation because table is empty, so no harm in leaving this here forever.
-        fwrite($fp, "ALTER TABLE `tiki_secdb` DROP PRIMARY KEY, ADD PRIMARY KEY (`filename`(186),`tiki_version`(5));\n\n");
+        fwrite($fp, "ALTER TABLE `tiki_secdb` DROP PRIMARY KEY, ADD PRIMARY KEY (`filename_hash`, `tiki_version`(20));\n\n");
 
-        $insertString = 'INSERT INTO `tiki_secdb` (`filename`, `md5_value`, `tiki_version`) VALUES ';
+        $insertString = 'INSERT INTO `tiki_secdb` (`filename`, `filename_hash`, `md5_value`, `tiki_version`) VALUES ';
 
         $extendedInsertSize = 0;
         $extendedInsertMaxSize = 1 * 1024 * 1024 - 100; // 1MB with 100 bytes safety limit, some old versions of Mysql had max_allowed_packet=1MB
@@ -419,7 +419,8 @@ function build_secdb_queries($dir, $version, &$queries, $excludes = [])
 
                 if (is_readable($entry)) {
                     $hash = md5_file($entry);
-                    $queries[] = "('$file', '$hash', '$version')";
+                    $filenameHash = md5($file);
+                    $queries[] = "('$file', '$filenameHash', '$hash', '$version')";
                 }
             }
         }



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/30f7fd63695378d48433d706abbbcfed7384c3ea

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/30f7fd63695378d48433d706abbbcfed7384c3ea
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.