No error should occur.
The module does get duplicated without any apparent trouble.
PHP Built On: Linux test-environment 6.8.0-57-generic 59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
Database Type: mysql
Database Version: 8.0.41-0ubuntu0.24.04.1
Database Collation: utf8mb4_unicode_ci
Database Connection Collation: utf8mb4_0900_ai_ci
Database Connection Encryption: None
Database Server Supports Connection Encryption: Yes
PHP Version: 8.2.28
Web Server: Apache/2.4.58 (Ubuntu)
WebServer to PHP Interface: apache2handler
Joomla! Version: Joomla! 5.2.6 Stable [ Uthabiti ] 8-April-2025 16:00 GMT
Joomla Backward Compatibility Plugin: Enabled (classes_aliases:"1", es5_assets:"1")
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Error also occurs on Windows and other browsers.
This error did not occur before J5.2.5. Persistent on J5.2.6
SP Page Builder v5.5.4 installed, HOWEVER, the module being duplicated is a standard Custom module with 3 lines of PHP code to add a datatable.
Helix Ultimate v2.1.2 installed.
Template is vhost_free_j5_2.1.9
As said before, error did not occur prior to J5.2.5.
This error was also reported in #44913 by someone else, but seems other folks could not reproduce the error.
Screenshots:
Labels |
Added:
No Code Attached Yet
|
Ok, here are the steps I took to replicate the problem. First, the #__usergroups table:
Please let me know if you need any further testing, etc. I'm a .NET programmer, so I can more or less navigate my way across php and js code, etc., if needed.
Thanks!
Are you using the sourcerer?
Could you replace the content of this module by a normal text and see if anything changes?
Could you change your environment and database collation? Maybe make a copy of your Installation.
I cannot replicate on any of my installations, with collation = utf8mb4_unicode_ci in the database.
No idea if this makes a difference.
Can someone kindly point me to the path and file (and approximate lines of code) that get invoked when duplicating a module? Maybe I can figure out what variables are getting sent to the SQL command to insert, etc. Any help would be greatly appreciated.
Found it:
administrator/components/com_modules/src/Model/ModuleModel.php
public function duplicate(&$pks)
/libraries/src/Table/Module.php
public function store($updateNulls = true)
/libraries/src/Table/Table.php
public function store($updateNulls = false)
Will post my findings.
Thanks
Just at the same place. in _getAssetPartentsId().
I see some old code - but it is not wrong. It could only fail if is something wrong in your #__assets table.
Well, this is strange...
So I put this here, in /libraries/vendor/joomla/database/src/Mysqli/MysqliDriver.php to catch the SQL statements:
I created a standard Custom Module with 'This is a test' (sans quotes) as the content. No errors on save.
I then duplicated it. Got the same (original) error. My 'log' showed this:
INSERT INTO `#__modules`
(`id`,`title`,`note`,`content`,`ordering`,`position`,`published`,`module`,`access`,`showtitle`,`params`,`client_id`,`language`) VALUES
('0','Test_Module','','<p>This is a test</p>','1','','1','mod_custom','1','1','{\"prepare_content\":0,\"backgroundimage\":\"\",\"layout\":\"_:default\",\"moduleclass_sfx\":\"\",\"cache\":1,\"cache_time\":900,\"cachemode\":\"static\",\"module_tag\":\"div\",\"bootstrap_size\":\"0\",\"header_tag\":\"h3\",\"header_class\":\"\",\"style\":\"0\"}','0','*')
INSERT INTO `#__assets`
(`parent_id`,`level`,`lft`,`rgt`,`name`,`title`,`rules`) VALUES
('18','2','224','225','com_modules.module.205','Test_Module','{}')
INSERT INTO `#__action_logs`
(`message_language_key`,`message`,`log_date`,`extension`,`user_id`,`ip_address`,`item_id`) VALUES
('PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED','{\"action\":\"add\",\"type\":\"PLG_ACTIONLOG_JOOMLA_TYPE_MODULE\",\"id\":205,\"title\":\"Test_Module\",\"extension_name\":\"Test_Module\",\"itemlink\":\"index.php?option=com_modules&task=module.edit&id=205\",\"userid\":834,\"username\":\"admin\",\"accountlink\":\"index.php?option=com_users&task=user.edit&id=834\"}','2025-04-15 20:07:45','com_modules.module','834','COM_ACTIONLOGS_DISABLED','205')
INSERT INTO `#__modules`
(`id`,`title`,`note`,`content`,`ordering`,`position`,`published`,`module`,`access`,`showtitle`,`params`,`client_id`,`language`) VALUES
('0','Test_Module (2)','','<p>This is a test</p>','1','','0','mod_custom','1','1','{\"prepare_content\":0,\"backgroundimage\":\"\",\"layout\":\"_:default\",\"moduleclass_sfx\":\"\",\"cache\":1,\"cache_time\":900,\"cachemode\":\"static\",\"module_tag\":\"div\",\"bootstrap_size\":\"0\",\"header_tag\":\"h3\",\"header_class\":\"\",\"style\":\"0\"}','0','*')
INSERT INTO `#__assets`
(`parent_id`,`level`,`lft`,`rgt`,`name`,`title`,`rules`) VALUES
('18','2','226','227','com_modules.module.206','Test_Module (2)','{}')
No lines after that...
Guessing that only the second INSERT 'must' contain the error (because of the 'access' field), I copied it to MySQL Workbench, modified the title (second field) and ran it. Forgot to change the table prefix on the first try (which is why I got an error), but after fixing that, it ran without problems...
I didn't run the assets and action_logs INSERTs, though.
Any thoughts?
Thanks!
Still unable to replicate that. ICould it be a wrong entry in your #__asset table? But it is really hard to check nested sets.
You could make a copy of your site, then replace the #__assets table by a #__assets table from a fresh installation. Just for test. This of course removes all existing permissions and is not a solution. But would give a hint if the poblem is the #__asset table itself.
As nobody can replicate this or opened a similiar issue, I cannot believe that it is a bug in Joomla core.
ahh.. thank you! Really strange.
@Molasar49 Test to duplicate a custom module and can't confirm the reported issue on a clean joomla installation using core components and no 3rd party extensions.
System Information
PHP Built On Linux lamp401.cloudaccess.net 5.14.0-503.15.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 28 07:25:19 EST 2024 x86_64
Database Type mysql
Database Version 10.11.11-MariaDB-cll-lve
Database Collation utf8mb3_general_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption No
PHP Version 8.3.19
Web Server Apache
WebServer to PHP Interface litespeed
Joomla! Version Joomla! 5.2.6 Stable [ Uthabiti ] 8-April-2025 16:00 GMT
Joomla Backward Compatibility Plugin Enabled (classes_aliases:"1", es5_assets:"1")
User Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0