Skip to content

Commit 8a55574

Browse files
authored
Merge pull request #160 from ggoffy/master
fixed bug in update function
2 parents aa6e546 + c0ad364 commit 8a55574

File tree

3 files changed

+42
-94
lines changed

3 files changed

+42
-94
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- removed unnecessary sprintf (goffy)
2424
- replace ternary expression by condition (goffy)
2525
- using same param name during inheritance (goffy)
26+
- fixed bug in update function (liomj/goffy)
2627

2728
<h5>3.5.1 Beta 1 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.25, PHP 8.0.12, PHP 8.1.0 Beta 4
2829
- semantic versioning (mamba)

files/commonfiles/include/update.php

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
function xoops_module_update_modulebuilder($module, $prev_version = null)
3232
{
3333
$ret = null;
34+
/*
3435
if ($prev_version < 10) {
35-
$ret = update_modulebuilder_v10($module);
36+
//enter code or call your function
3637
}
37-
38+
*/
3839
$ret = modulebuilder_check_db($module);
3940

4041
//check upload directory
@@ -49,60 +50,6 @@ function xoops_module_update_modulebuilder($module, $prev_version = null)
4950
return $ret;
5051
}
5152

52-
// irmtfan bug fix: solve templates duplicate issue
53-
/**
54-
* @param $module
55-
*
56-
* @return bool
57-
*/
58-
function update_modulebuilder_v10($module)
59-
{
60-
global $xoopsDB;
61-
$result = $xoopsDB->query(
62-
'SELECT t1.tpl_id FROM ' . $xoopsDB->prefix('tplfile') . ' t1, ' . $xoopsDB->prefix('tplfile') . ' t2 WHERE t1.tpl_refid = t2.tpl_refid AND t1.tpl_module = t2.tpl_module AND t1.tpl_tplset=t2.tpl_tplset AND t1.tpl_file = t2.tpl_file AND t1.tpl_type = t2.tpl_type AND t1.tpl_id > t2.tpl_id'
63-
);
64-
$tplids = [];
65-
while ([$tplid] = $xoopsDB->fetchRow($result)) {
66-
$tplids[] = $tplid;
67-
}
68-
if (\count($tplids) > 0) {
69-
$tplfileHandler = \xoops_getHandler('tplfile');
70-
$duplicate_files = $tplfileHandler->getObjects(new \Criteria('tpl_id', '(' . \implode(',', $tplids) . ')', 'IN'));
71-
72-
if (\count($duplicate_files) > 0) {
73-
foreach (\array_keys($duplicate_files) as $i) {
74-
$tplfileHandler->delete($duplicate_files[$i]);
75-
}
76-
}
77-
}
78-
$sql = 'SHOW INDEX FROM ' . $xoopsDB->prefix('tplfile') . " WHERE KEY_NAME = 'tpl_refid_module_set_file_type'";
79-
if (!$result = $xoopsDB->queryF($sql)) {
80-
xoops_error($xoopsDB->error() . '<br>' . $sql);
81-
82-
return false;
83-
}
84-
$ret = [];
85-
while (false !== ($myrow = $xoopsDB->fetchArray($result))) {
86-
$ret[] = $myrow;
87-
}
88-
if (!empty($ret)) {
89-
$module->setErrors("'tpl_refid_module_set_file_type' unique index is exist. Note: check 'tplfile' table to be sure this index is UNIQUE because XOOPS CORE need it.");
90-
91-
return true;
92-
}
93-
$sql = 'ALTER TABLE ' . $xoopsDB->prefix('tplfile') . ' ADD UNIQUE tpl_refid_module_set_file_type ( tpl_refid, tpl_module, tpl_tplset, tpl_file, tpl_type )';
94-
if (!$result = $xoopsDB->queryF($sql)) {
95-
xoops_error($xoopsDB->error() . '<br>' . $sql);
96-
$module->setErrors("'tpl_refid_module_set_file_type' unique index is not added to 'tplfile' table. Warning: do not use XOOPS until you add this unique index.");
97-
98-
return false;
99-
}
100-
101-
return true;
102-
}
103-
104-
// irmtfan bug fix: solve templates duplicate issue
105-
10653
/**
10754
* @param $module
10855
*

sql/mysql.sql

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@
1313

1414
CREATE TABLE `modulebuilder_settings` (
1515
`set_id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
16-
`set_name` VARCHAR(255) NOT NULL DEFAULT 'My Module',
17-
`set_dirname` VARCHAR(100) NOT NULL DEFAULT 'mymoduledirname',
18-
`set_version` VARCHAR(10) NOT NULL DEFAULT '1.0.0',
19-
`set_since` VARCHAR(5) NOT NULL DEFAULT '1.0.0',
20-
`set_min_php` VARCHAR(5) NOT NULL DEFAULT '7.0',
21-
`set_min_xoops` VARCHAR(15) NOT NULL DEFAULT '2.5.10',
22-
`set_min_admin` VARCHAR(8) NOT NULL DEFAULT '1.2',
23-
`set_min_mysql` VARCHAR(8) NOT NULL DEFAULT '5.5',
24-
`set_description` VARCHAR(255) NOT NULL DEFAULT 'This module is for doing following...',
25-
`set_author` VARCHAR(255) NOT NULL DEFAULT 'TDM XOOPS',
26-
`set_author_mail` VARCHAR(255) NOT NULL DEFAULT '[email protected]',
27-
`set_author_website_url` VARCHAR(255) NOT NULL DEFAULT 'http://xoops.org',
28-
`set_author_website_name` VARCHAR(255) NOT NULL DEFAULT 'XOOPS Project',
29-
`set_credits` VARCHAR(255) NOT NULL DEFAULT 'XOOPS Development Team',
30-
`set_license` VARCHAR(255) NOT NULL DEFAULT 'GPL 2.0 or later',
31-
`set_release_info` VARCHAR(255) NOT NULL DEFAULT 'release_info',
32-
`set_release_file` VARCHAR(255) NOT NULL DEFAULT 'release_info file',
33-
`set_manual` VARCHAR(255) NOT NULL DEFAULT 'link to manual file',
34-
`set_manual_file` VARCHAR(255) NOT NULL DEFAULT 'install.txt',
35-
`set_image` VARCHAR(255) NOT NULL DEFAULT 'empty.png',
36-
`set_demo_site_url` VARCHAR(255) NOT NULL DEFAULT 'https://xoops.org',
37-
`set_demo_site_name` VARCHAR(255) NOT NULL DEFAULT 'XOOPS Demo Site',
38-
`set_support_url` VARCHAR(255) NOT NULL DEFAULT 'http://xoops.org/modules/newbb',
39-
`set_support_name` VARCHAR(255) NOT NULL DEFAULT 'Support Forum',
40-
`set_website_url` VARCHAR(255) NOT NULL DEFAULT 'www.xoops.org',
41-
`set_website_name` VARCHAR(255) NOT NULL DEFAULT 'XOOPS Project',
42-
`set_release` VARCHAR(11) NOT NULL DEFAULT '2015-05-02',
43-
`set_status` VARCHAR(150) NOT NULL DEFAULT 'Beta 1',
16+
`set_name` VARCHAR(255) NOT NULL DEFAULT '',
17+
`set_dirname` VARCHAR(100) NOT NULL DEFAULT '',
18+
`set_version` VARCHAR(15) NOT NULL DEFAULT '',
19+
`set_since` VARCHAR(15) NOT NULL DEFAULT '',
20+
`set_min_php` VARCHAR(15) NOT NULL DEFAULT '',
21+
`set_min_xoops` VARCHAR(15) NOT NULL DEFAULT '',
22+
`set_min_admin` VARCHAR(15) NOT NULL DEFAULT '',
23+
`set_min_mysql` VARCHAR(15) NOT NULL DEFAULT '',
24+
`set_description` VARCHAR(255) NOT NULL DEFAULT '',
25+
`set_author` VARCHAR(255) NOT NULL DEFAULT '',
26+
`set_author_mail` VARCHAR(255) NOT NULL DEFAULT '',
27+
`set_author_website_url` VARCHAR(255) NOT NULL DEFAULT '',
28+
`set_author_website_name` VARCHAR(255) NOT NULL DEFAULT '',
29+
`set_credits` VARCHAR(255) NOT NULL DEFAULT '',
30+
`set_license` VARCHAR(255) NOT NULL DEFAULT '',
31+
`set_release_info` VARCHAR(255) NOT NULL DEFAULT '',
32+
`set_release_file` VARCHAR(255) NOT NULL DEFAULT '',
33+
`set_manual` VARCHAR(255) NOT NULL DEFAULT '',
34+
`set_manual_file` VARCHAR(255) NOT NULL DEFAULT '',
35+
`set_image` VARCHAR(255) NOT NULL DEFAULT '',
36+
`set_demo_site_url` VARCHAR(255) NOT NULL DEFAULT '',
37+
`set_demo_site_name` VARCHAR(255) NOT NULL DEFAULT '',
38+
`set_support_url` VARCHAR(255) NOT NULL DEFAULT '',
39+
`set_support_name` VARCHAR(255) NOT NULL DEFAULT '',
40+
`set_website_url` VARCHAR(255) NOT NULL DEFAULT '',
41+
`set_website_name` VARCHAR(255) NOT NULL DEFAULT '',
42+
`set_release` VARCHAR(11) NOT NULL DEFAULT '',
43+
`set_status` VARCHAR(150) NOT NULL DEFAULT '',
4444
`set_admin` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
4545
`set_user` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
4646
`set_blocks` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
@@ -49,8 +49,8 @@ CREATE TABLE `modulebuilder_settings` (
4949
`set_notifications` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
5050
`set_permissions` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
5151
`set_inroot_copy` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
52-
`set_donations` VARCHAR(50) NOT NULL DEFAULT '6KJ7RW5DR3VTJ',
53-
`set_subversion` VARCHAR(10) NOT NULL DEFAULT '13070',
52+
`set_donations` VARCHAR(50) NOT NULL DEFAULT '',
53+
`set_subversion` VARCHAR(10) NOT NULL DEFAULT '',
5454
`set_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
5555
PRIMARY KEY (`set_id`)
5656
)
@@ -60,7 +60,7 @@ CREATE TABLE `modulebuilder_settings` (
6060

6161
INSERT INTO `modulebuilder_settings` (`set_id`, `set_name`, `set_dirname`, `set_version`, `set_since`, `set_min_php`, `set_min_xoops`, `set_min_admin`, `set_min_mysql`, `set_description`, `set_author`, `set_author_mail`, `set_author_website_url`, `set_author_website_name`, `set_credits`, `set_license`, `set_release_info`, `set_release_file`, `set_manual`, `set_manual_file`, `set_image`, `set_demo_site_url`, `set_demo_site_name`, `set_support_url`, `set_support_name`, `set_website_url`, `set_website_name`, `set_release`, `set_status`, `set_admin`, `set_user`, `set_blocks`, `set_search`, `set_comments`, `set_notifications`, `set_permissions`, `set_inroot_copy`, `set_donations`, `set_subversion`, `set_type`)
6262
VALUES
63-
(1, 'My Module', 'mymoduledirname', '1.0.0', '1.0.0', '7.0', '2.5.10', '1.2', '5.6', 'This module is for doing following...', 'TDM XOOPS', '[email protected]', 'http://xoops.org', 'XOOPS Project', 'XOOPS Development Team', 'GPL 2.0 or later', 'release_info', 'release_info file', 'link to manual file',
63+
(1, 'My Module', 'mymoduledirname', '1.0.0', '1.0.0', '7.0', '2.5.10', '1.2', '5.6', 'This module is for doing following...', 'TDM XOOPS', '[email protected]', 'https://xoops.org', 'XOOPS Project', 'XOOPS Development Team', 'GPL 2.0 or later', 'release_info', 'release_info file', 'link to manual file',
6464
'install.txt', 'empty.png', 'https://xoops.org', 'XOOPS Demo Site', 'https://xoops.org/modules/newbb', 'Support Forum', 'www.xoops.org', 'XOOPS Project',
6565
'2017-12-02', 'Beta 1', '1', '1', '1', '0', '0', '0', '0', '0', '6KJ7RW5DR3VTJ', '13070', 1);
6666

@@ -72,12 +72,12 @@ CREATE TABLE `modulebuilder_modules` (
7272
`mod_id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
7373
`mod_name` VARCHAR(200) NOT NULL DEFAULT '',
7474
`mod_dirname` VARCHAR(100) NOT NULL DEFAULT '',
75-
`mod_version` VARCHAR(10) NOT NULL DEFAULT '1.0.0',
76-
`mod_since` VARCHAR(10) NOT NULL DEFAULT '1.0.0',
77-
`mod_min_php` VARCHAR(4) NOT NULL DEFAULT '5.5',
75+
`mod_version` VARCHAR(15) NOT NULL DEFAULT '1.0.0',
76+
`mod_since` VARCHAR(15) NOT NULL DEFAULT '1.0.0',
77+
`mod_min_php` VARCHAR(15) NOT NULL DEFAULT '5.5',
7878
`mod_min_xoops` VARCHAR(15) NOT NULL DEFAULT '2.5.11',
79-
`mod_min_admin` VARCHAR(4) NOT NULL DEFAULT '1.2',
80-
`mod_min_mysql` VARCHAR(6) NOT NULL DEFAULT '5.5',
79+
`mod_min_admin` VARCHAR(15) NOT NULL DEFAULT '1.2',
80+
`mod_min_mysql` VARCHAR(15) NOT NULL DEFAULT '5.5',
8181
`mod_description` TEXT,
8282
`mod_author` VARCHAR(200) NOT NULL DEFAULT 'TDM XOOPS',
8383
`mod_author_mail` VARCHAR(200) NOT NULL DEFAULT '[email protected]',
@@ -106,8 +106,8 @@ CREATE TABLE `modulebuilder_modules` (
106106
`mod_notifications` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
107107
`mod_permissions` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
108108
`mod_inroot_copy` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
109-
`mod_donations` VARCHAR(50) NOT NULL DEFAULT '6KJ7RW5DR3VTJ',
110-
`mod_subversion` VARCHAR(10) NOT NULL DEFAULT '12550',
109+
`mod_donations` VARCHAR(50) NOT NULL DEFAULT '',
110+
`mod_subversion` VARCHAR(10) NOT NULL DEFAULT '',
111111
PRIMARY KEY (`mod_id`),
112112
KEY `mod_name` (`mod_name`),
113113
UNIQUE KEY `mod_dirname` (`mod_dirname`)

0 commit comments

Comments
 (0)