diff --git a/README.md b/README.md index 600aac664..737b9dbd6 100644 --- a/README.md +++ b/README.md @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 10th December, 2020 ++ *Last Build*: 11th December, 2020 + *Version*: 2.12.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **290450** ++ *Line count*: **290481** + *Field count*: **1555** + *File count*: **1923** + *Folder count*: **316** diff --git a/admin/README.txt b/admin/README.txt index 600aac664..737b9dbd6 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 10th December, 2020 ++ *Last Build*: 11th December, 2020 + *Version*: 2.12.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **290450** ++ *Line count*: **290481** + *Field count*: **1555** + *File count*: **1923** + *Folder count*: **316** diff --git a/admin/config.xml b/admin/config.xml index dee87c85f..e1e80d6fe 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -767,7 +767,7 @@ description="COM_COMPONENTBUILDER_CONFIG_ASSETS_TABLE_FIX_DESCRIPTION" class="list_class" multiple="false" - default="1"> + default="2"> diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 1bc5b0fd8..1dece8ffb 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -7969,7 +7969,7 @@ class Interpretation extends Fields 'php_postflight', 'install', PHP_EOL . PHP_EOL, null, true ); // add the Intelligent Fix script if needed - $script .= $this->getAssetsTableIntelligentFix(); + $script .= $this->getAssetsTableIntelligentInstall(); // add the component install notice if (ComponentbuilderHelper::checkString($script)) { @@ -8494,7 +8494,7 @@ class Interpretation extends Fields $script .= PHP_EOL; } // add the Intelligent Reversal script if needed - $script .= $this->getAssetsTableIntelligentReversal(); + $script .= $this->getAssetsTableIntelligentUninstall(); // add the custom uninstall script $script .= $this->getCustomScriptBuilder( 'php_method', 'uninstall', "", null, true, null, PHP_EOL @@ -8509,18 +8509,57 @@ class Interpretation extends Fields * @return string The php to place in script.php * */ - protected function getAssetsTableIntelligentFix() + protected function getAssetsTableIntelligentInstall() { + // WHY DO WE NEED AN ASSET TABLE FIX? + // https://www.mysqltutorial.org/mysql-varchar/ + // https://stackoverflow.com/a/15227917/1429677 + // https://forums.mysql.com/read.php?24,105964,105964 + // https://github.com/vdm-io/Joomla-Component-Builder/issues/616#issuecomment-741502980 + // 30 actions each +-20 characters with 8 groups + // that makes 4800 characters and the current Joomla + // column size is varchar(5120) + // check if we should add the intelligent fix treatment for the assets table - if ($this->addAssetsTableFix == 2 && $this->accessSize <= 400) + if ($this->addAssetsTableFix == 2) { - // reset script + // get the worse case column size required (can be worse I know) + // access/action size x 20 characters x 8 groups + $character_length = (int) ComponentbuilderHelper::bcmath( + 'mul', $this->accessSize, 20, 0 + ); + $character_length = (int) ComponentbuilderHelper::bcmath( + 'mul', $character_length, 8, 0 + ); + // get the type we will convert to + $data_type = ($character_length > 64000) ? "MEDIUMTEXT" : "TEXT"; + // the if statement about $rule_length + $codeIF = "\$rule_length <= " . $character_length; + // fix column size $script = array(); - $script[] = $this->_t(2) . "//" . $this->setLine(__LINE__) - . " Check what size the rules column is now"; + $script[] = $this->_t(5) . "//" . $this->setLine(__LINE__) + . " Fix the assets table rules column size"; + $script[] = $this->_t(5) + . '$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` ' + . $data_type + . ' NOT NULL COMMENT \'JSON encoded access control. Enlarged to ' . $data_type . ' by JCB\';";'; + $script[] = $this->_t(5) . "\$db->setQuery(\$fix_rules_size);"; + $script[] = $this->_t(5) . "\$db->execute();"; + $codeA = implode(PHP_EOL, $script); + // fixed message + $messageA = $this->_t(5) + . "\$app->enqueueMessage(JText::_('The #__assets table rules column was resized to the " + . $data_type + . " datatype for the components possible large permission rules.'));"; + // do nothing + $codeB = ""; + // fix not needed so ignore + $messageB = ""; // done - return PHP_EOL . implode(PHP_EOL, $script); + return $this->getAssetsTableIntelligentCode( + $codeIF, $codeA, $codeB, $messageA, $messageB, 2 + ); } return ''; @@ -8532,23 +8571,96 @@ class Interpretation extends Fields * @return string The php to place in script.php * */ - protected function getAssetsTableIntelligentReversal() + protected function getAssetsTableIntelligentUninstall() { // check if we should add the intelligent uninstall treatment for the assets table if ($this->addAssetsTableFix == 2) { - // reset script + // the if statement about $rule_length + $codeIF = "\$rule_length < 5120"; + // reverse column size $script = array(); - $script[] = $this->_t(2) . "//" . $this->setLine(__LINE__) - . " Check for the biggest rules item in the database at this point"; + $script[] = $this->_t(4) . "//" . $this->setLine(__LINE__) + . " Revert the assets table rules column back to the default"; + $script[] = $this->_t(4) + . '$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT \'JSON encoded access control.\';";'; + $script[] = $this->_t(4) . "\$db->setQuery(\$revert_rule);"; + $script[] = $this->_t(4) . "\$db->execute();"; + $codeA = implode(PHP_EOL, $script); + // reverted message + $messageA = $this->_t(4) + . "\$app->enqueueMessage(JText::_('Reverted the #__assets table rules column back to its default size of varchar(5120)'));"; + // do nothing + $codeB = ""; + // not reverted message + $messageB = $this->_t(4) + . "\$app->enqueueMessage(JText::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));"; // done - return PHP_EOL . implode(PHP_EOL, $script); + return $this->getAssetsTableIntelligentCode( + $codeIF, $codeA, $codeB, $messageA, $messageB + ); } return ''; } + /** + * set code for both install, update and uninstall + * + * @param string $codeIF The IF code to fix this issue + * @param string $codeA The a code to fix this issue + * @param string $codeB The b code to fix this issue + * @param string $messageA The fix a message + * @param string $messageB The fix b message + * + * @return string + * + */ + protected function getAssetsTableIntelligentCode($codeIF, $codeA, $codeB, + $messageA, $messageB, $tab = 1 + ) { + // reset script + $script = array(); + $script[] = $this->_t($tab) . $this->_t(1) . "//" . $this->setLine( + __LINE__ + ) + . " Get the biggest rule column in the assets table at this point."; + $script[] = $this->_t($tab) . $this->_t(1) + . '$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";'; + $script[] = $this->_t($tab) . $this->_t(1) + . "\$db->setQuery(\$get_rule_length);"; + $script[] = $this->_t($tab) . $this->_t(1) . "if (\$db->execute())"; + $script[] = $this->_t($tab) . $this->_t(1) . "{"; + $script[] = $this->_t($tab) . $this->_t(2) + . "\$rule_length = \$db->loadResult();"; + // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 + // Checked 1st December 2020 (let us know if this changes) + $script[] = $this->_t($tab) . $this->_t(2) . "//" . $this->setLine( + __LINE__ + ) + . " Check the size of the rules column"; + $script[] = $this->_t($tab) . $this->_t(2) . "if (" . $codeIF . ")"; + $script[] = $this->_t($tab) . $this->_t(2) . "{"; + $script[] = $codeA; + $script[] = $messageA; + $script[] = $this->_t($tab) . $this->_t(2) . "}"; + // only ad this if there is a B part + if (ComponentbuilderHelper::checkString($codeB) + || ComponentbuilderHelper::checkString($messageB)) + { + $script[] = $this->_t($tab) . $this->_t(2) . "else"; + $script[] = $this->_t($tab) . $this->_t(2) . "{"; + $script[] = $codeB; + $script[] = $messageB; + $script[] = $this->_t($tab) . $this->_t(2) . "}"; + } + $script[] = $this->_t($tab) . $this->_t(1) . "}"; + + // done + return PHP_EOL . implode(PHP_EOL, $script); + } + public function setMoveFolderScript() { if ($this->setMoveFolders) @@ -10530,9 +10642,9 @@ class Interpretation extends Fields // check if this component needs larger rules // also check if the developer will allow this - // any value above 0 allows for the change to be added // the access actions length must be checked before this - if ($this->addAssetsTableFix) + // only add this option if set to SQL fix + if ($this->addAssetsTableFix == 1) { // 400 actions worse case is larger the 65535 characters if ($this->accessSize > 400) @@ -10549,7 +10661,6 @@ class Interpretation extends Fields . "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control.';"; } // smaller then 400 makes TEXT large enough - // only add this option if set to SQL fix elseif ($this->addAssetsTableFix == 1) { $db .= PHP_EOL; @@ -10567,8 +10678,8 @@ class Interpretation extends Fields // check if this component needs larger names // also check if the developer will allow this - // any value above 0 allows for the change to be added // the config length must be checked before this + // only add this option if set to SQL fix if ($this->addAssetsTableFix && $this->addAssetsTableNameFix) { $db .= PHP_EOL; @@ -10617,7 +10728,7 @@ class Interpretation extends Fields // check if this component used larger rules // now revert them back on uninstall - // number 1 allows for the change to be reversed + // only add this option if set to SQL fix if ($this->addAssetsTableFix == 1) { // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 @@ -10636,7 +10747,7 @@ class Interpretation extends Fields // check if this component used larger names // now revert them back on uninstall - // number 1 allows for the change to be reversed + // only add this option if set to SQL fix if ($this->addAssetsTableFix == 1 && $this->addAssetsTableNameFix) { // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L20 @@ -20573,9 +20684,9 @@ class Interpretation extends Fields /** * Add the code of the stored ids * - * @param array $filter The field/filter array - * @param string $nameListCode The list view name - * @param string $Component The Component name + * @param array $filter The field/filter array + * @param string $nameListCode The list view name + * @param string $Component The Component name * * @return string The code for the stored IDs * @@ -20602,10 +20713,14 @@ class Interpretation extends Fields else { $stored = $this->getStoredIdCodeMulti('category', $Component); - $stored .= $this->getStoredIdCodeMulti('category_id', $Component); + $stored .= $this->getStoredIdCodeMulti( + 'category_id', $Component + ); if ($filter['code'] != 'category') { - $stored .= $this->getStoredIdCodeMulti($filter['code'], $Component); + $stored .= $this->getStoredIdCodeMulti( + $filter['code'], $Component + ); } } } @@ -20618,7 +20733,9 @@ class Interpretation extends Fields { // top bar selection can result in // an array due to multi selection - $stored = $this->getStoredIdCodeMulti($filter['code'], $Component); + $stored = $this->getStoredIdCodeMulti( + $filter['code'], $Component + ); } else { @@ -20634,8 +20751,8 @@ class Interpretation extends Fields /** * Add the code of the stored multi ids * - * @param string $key The key field name - * @param string $Component The Component name + * @param string $key The key field name + * @param string $Component The Component name * * @return string The code for the stored IDs * @@ -20661,7 +20778,7 @@ class Interpretation extends Fields . "}"; $stored .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) - . " Check if this is only an int or string"; + . " Check if this is only an number or string"; $stored .= PHP_EOL . $this->_t(2) . "elseif (is_numeric(\$_" . $key . ")"; $stored .= PHP_EOL . $this->_t(2) @@ -27067,7 +27184,7 @@ function vdm_dkim() { $this->componentGlobal = null; $this->permissionViews = null; - // remove the fix in not needed + // remove the fix, is not needed if ($this->accessSize < 30) { // since we have less than 30 actions diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php index 450cb98a8..642265c20 100644 --- a/admin/models/admin_views.php +++ b/admin/models/admin_views.php @@ -685,7 +685,7 @@ class ComponentbuilderModelAdmin_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { @@ -701,7 +701,7 @@ class ComponentbuilderModelAdmin_views extends JModelList { $id .= ':' . implode(':', $_type); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_type) || ComponentbuilderHelper::checkString($_type)) { diff --git a/admin/models/admins_custom_tabs.php b/admin/models/admins_custom_tabs.php index 9a65ad024..883ac7992 100644 --- a/admin/models/admins_custom_tabs.php +++ b/admin/models/admins_custom_tabs.php @@ -210,7 +210,7 @@ class ComponentbuilderModelAdmins_custom_tabs extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/admins_fields.php b/admin/models/admins_fields.php index 840b6d443..fa70e06ac 100644 --- a/admin/models/admins_fields.php +++ b/admin/models/admins_fields.php @@ -210,7 +210,7 @@ class ComponentbuilderModelAdmins_fields extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/admins_fields_conditions.php b/admin/models/admins_fields_conditions.php index 4139aa5f4..5e67665e5 100644 --- a/admin/models/admins_fields_conditions.php +++ b/admin/models/admins_fields_conditions.php @@ -210,7 +210,7 @@ class ComponentbuilderModelAdmins_fields_conditions extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/admins_fields_relations.php b/admin/models/admins_fields_relations.php index b859e5ac6..9fd123546 100644 --- a/admin/models/admins_fields_relations.php +++ b/admin/models/admins_fields_relations.php @@ -210,7 +210,7 @@ class ComponentbuilderModelAdmins_fields_relations extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/class_extendings.php b/admin/models/class_extendings.php index a99dda834..0b2da5e46 100644 --- a/admin/models/class_extendings.php +++ b/admin/models/class_extendings.php @@ -290,7 +290,7 @@ class ComponentbuilderModelClass_extendings extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/class_methods.php b/admin/models/class_methods.php index 0736ca5d7..93d89de09 100644 --- a/admin/models/class_methods.php +++ b/admin/models/class_methods.php @@ -463,7 +463,7 @@ class ComponentbuilderModelClass_methods extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/class_properties.php b/admin/models/class_properties.php index ba7c42714..5920ed840 100644 --- a/admin/models/class_properties.php +++ b/admin/models/class_properties.php @@ -461,7 +461,7 @@ class ComponentbuilderModelClass_properties extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_admin_views.php b/admin/models/components_admin_views.php index 2d0d9e7d3..af4c4dd08 100644 --- a/admin/models/components_admin_views.php +++ b/admin/models/components_admin_views.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_admin_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_config.php b/admin/models/components_config.php index 68431a56e..5d476d110 100644 --- a/admin/models/components_config.php +++ b/admin/models/components_config.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_config extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_custom_admin_menus.php b/admin/models/components_custom_admin_menus.php index 1637b03fe..63d38a372 100644 --- a/admin/models/components_custom_admin_menus.php +++ b/admin/models/components_custom_admin_menus.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_custom_admin_menus extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_custom_admin_views.php b/admin/models/components_custom_admin_views.php index 4ac7142f7..6bd59a66e 100644 --- a/admin/models/components_custom_admin_views.php +++ b/admin/models/components_custom_admin_views.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_custom_admin_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_dashboard.php b/admin/models/components_dashboard.php index 111597186..d7b0e7e85 100644 --- a/admin/models/components_dashboard.php +++ b/admin/models/components_dashboard.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_dashboard extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_files_folders.php b/admin/models/components_files_folders.php index 85b03e6f0..7bf0f8c25 100644 --- a/admin/models/components_files_folders.php +++ b/admin/models/components_files_folders.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_files_folders extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_modules.php b/admin/models/components_modules.php index 9b6bcd006..ea48f2ff7 100644 --- a/admin/models/components_modules.php +++ b/admin/models/components_modules.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_modules extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_mysql_tweaks.php b/admin/models/components_mysql_tweaks.php index d32ef356c..e810ab174 100644 --- a/admin/models/components_mysql_tweaks.php +++ b/admin/models/components_mysql_tweaks.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_mysql_tweaks extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_placeholders.php b/admin/models/components_placeholders.php index c7cdb9b5a..9d8031246 100644 --- a/admin/models/components_placeholders.php +++ b/admin/models/components_placeholders.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_placeholders extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_plugins.php b/admin/models/components_plugins.php index fb0f42954..3cea9f8cf 100644 --- a/admin/models/components_plugins.php +++ b/admin/models/components_plugins.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_plugins extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_site_views.php b/admin/models/components_site_views.php index 436951d1b..2bc0d8597 100644 --- a/admin/models/components_site_views.php +++ b/admin/models/components_site_views.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_site_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/components_updates.php b/admin/models/components_updates.php index 5fa4ba231..280753460 100644 --- a/admin/models/components_updates.php +++ b/admin/models/components_updates.php @@ -210,7 +210,7 @@ class ComponentbuilderModelComponents_updates extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/custom_admin_views.php b/admin/models/custom_admin_views.php index 3de52a967..6c833886f 100644 --- a/admin/models/custom_admin_views.php +++ b/admin/models/custom_admin_views.php @@ -519,7 +519,7 @@ class ComponentbuilderModelCustom_admin_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/custom_codes.php b/admin/models/custom_codes.php index 01ed00528..9a0d61bde 100644 --- a/admin/models/custom_codes.php +++ b/admin/models/custom_codes.php @@ -555,7 +555,7 @@ class ComponentbuilderModelCustom_codes extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/dynamic_gets.php b/admin/models/dynamic_gets.php index aea7abf8c..b6a2a3b44 100644 --- a/admin/models/dynamic_gets.php +++ b/admin/models/dynamic_gets.php @@ -470,7 +470,7 @@ class ComponentbuilderModelDynamic_gets extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/fields.php b/admin/models/fields.php index 4510f5e4d..297c33a20 100644 --- a/admin/models/fields.php +++ b/admin/models/fields.php @@ -638,7 +638,7 @@ class ComponentbuilderModelFields extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { @@ -658,7 +658,7 @@ class ComponentbuilderModelFields extends JModelList { $id .= ':' . implode(':', $_category); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_category) || ComponentbuilderHelper::checkString($_category)) { @@ -670,7 +670,7 @@ class ComponentbuilderModelFields extends JModelList { $id .= ':' . implode(':', $_category_id); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_category_id) || ComponentbuilderHelper::checkString($_category_id)) { @@ -682,7 +682,7 @@ class ComponentbuilderModelFields extends JModelList { $id .= ':' . implode(':', $_catid); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_catid) || ComponentbuilderHelper::checkString($_catid)) { diff --git a/admin/models/fieldtypes.php b/admin/models/fieldtypes.php index 27eec758e..9546781aa 100644 --- a/admin/models/fieldtypes.php +++ b/admin/models/fieldtypes.php @@ -399,7 +399,7 @@ class ComponentbuilderModelFieldtypes extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { @@ -414,7 +414,7 @@ class ComponentbuilderModelFieldtypes extends JModelList { $id .= ':' . implode(':', $_category); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_category) || ComponentbuilderHelper::checkString($_category)) { @@ -426,7 +426,7 @@ class ComponentbuilderModelFieldtypes extends JModelList { $id .= ':' . implode(':', $_category_id); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_category_id) || ComponentbuilderHelper::checkString($_category_id)) { @@ -438,7 +438,7 @@ class ComponentbuilderModelFieldtypes extends JModelList { $id .= ':' . implode(':', $_catid); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_catid) || ComponentbuilderHelper::checkString($_catid)) { diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index 19c71ecea..62072d7c9 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -2517,7 +2517,7 @@ class ComponentbuilderModelJoomla_components extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_modules.php b/admin/models/joomla_modules.php index 06cd3d68f..998cf15b5 100644 --- a/admin/models/joomla_modules.php +++ b/admin/models/joomla_modules.php @@ -296,7 +296,7 @@ class ComponentbuilderModelJoomla_modules extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_modules_files_folders_urls.php b/admin/models/joomla_modules_files_folders_urls.php index 6fffef411..9c5894239 100644 --- a/admin/models/joomla_modules_files_folders_urls.php +++ b/admin/models/joomla_modules_files_folders_urls.php @@ -210,7 +210,7 @@ class ComponentbuilderModelJoomla_modules_files_folders_urls extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_modules_updates.php b/admin/models/joomla_modules_updates.php index 9cf22bccc..d7fa50f39 100644 --- a/admin/models/joomla_modules_updates.php +++ b/admin/models/joomla_modules_updates.php @@ -210,7 +210,7 @@ class ComponentbuilderModelJoomla_modules_updates extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_plugin_groups.php b/admin/models/joomla_plugin_groups.php index edcd23c2c..6a8061839 100644 --- a/admin/models/joomla_plugin_groups.php +++ b/admin/models/joomla_plugin_groups.php @@ -237,7 +237,7 @@ class ComponentbuilderModelJoomla_plugin_groups extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_plugins.php b/admin/models/joomla_plugins.php index d0cd00eed..fe9ff6ca6 100644 --- a/admin/models/joomla_plugins.php +++ b/admin/models/joomla_plugins.php @@ -457,7 +457,7 @@ class ComponentbuilderModelJoomla_plugins extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_plugins_files_folders_urls.php b/admin/models/joomla_plugins_files_folders_urls.php index dc4918b83..f4289c86d 100644 --- a/admin/models/joomla_plugins_files_folders_urls.php +++ b/admin/models/joomla_plugins_files_folders_urls.php @@ -210,7 +210,7 @@ class ComponentbuilderModelJoomla_plugins_files_folders_urls extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/joomla_plugins_updates.php b/admin/models/joomla_plugins_updates.php index c5761e8da..9494d0eb7 100644 --- a/admin/models/joomla_plugins_updates.php +++ b/admin/models/joomla_plugins_updates.php @@ -210,7 +210,7 @@ class ComponentbuilderModelJoomla_plugins_updates extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/language_translations.php b/admin/models/language_translations.php index 0709e65e2..07b57d4e1 100644 --- a/admin/models/language_translations.php +++ b/admin/models/language_translations.php @@ -456,7 +456,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/languages.php b/admin/models/languages.php index 9976645b5..d63634c04 100644 --- a/admin/models/languages.php +++ b/admin/models/languages.php @@ -482,7 +482,7 @@ class ComponentbuilderModelLanguages extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/layouts.php b/admin/models/layouts.php index db4e5aaeb..8a2872e5c 100644 --- a/admin/models/layouts.php +++ b/admin/models/layouts.php @@ -451,7 +451,7 @@ class ComponentbuilderModelLayouts extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/libraries.php b/admin/models/libraries.php index 89b9bc6b6..63d022c22 100644 --- a/admin/models/libraries.php +++ b/admin/models/libraries.php @@ -383,7 +383,7 @@ class ComponentbuilderModelLibraries extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/libraries_config.php b/admin/models/libraries_config.php index df0c18479..4f3fa78dc 100644 --- a/admin/models/libraries_config.php +++ b/admin/models/libraries_config.php @@ -210,7 +210,7 @@ class ComponentbuilderModelLibraries_config extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/libraries_files_folders_urls.php b/admin/models/libraries_files_folders_urls.php index 1faeef8a5..08092d837 100644 --- a/admin/models/libraries_files_folders_urls.php +++ b/admin/models/libraries_files_folders_urls.php @@ -210,7 +210,7 @@ class ComponentbuilderModelLibraries_files_folders_urls extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/placeholders.php b/admin/models/placeholders.php index b7fc3408f..6b970f9cc 100644 --- a/admin/models/placeholders.php +++ b/admin/models/placeholders.php @@ -363,7 +363,7 @@ class ComponentbuilderModelPlaceholders extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/servers.php b/admin/models/servers.php index 224d7a0af..929b17c6c 100644 --- a/admin/models/servers.php +++ b/admin/models/servers.php @@ -478,7 +478,7 @@ class ComponentbuilderModelServers extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/site_views.php b/admin/models/site_views.php index 735139494..e503dcd88 100644 --- a/admin/models/site_views.php +++ b/admin/models/site_views.php @@ -527,7 +527,7 @@ class ComponentbuilderModelSite_views extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/snippet_types.php b/admin/models/snippet_types.php index 04110553c..a6a457a51 100644 --- a/admin/models/snippet_types.php +++ b/admin/models/snippet_types.php @@ -237,7 +237,7 @@ class ComponentbuilderModelSnippet_types extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/snippets.php b/admin/models/snippets.php index 70570d13c..e88f8e1c7 100644 --- a/admin/models/snippets.php +++ b/admin/models/snippets.php @@ -541,7 +541,7 @@ class ComponentbuilderModelSnippets extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/templates.php b/admin/models/templates.php index aa9b761a7..29e0521e8 100644 --- a/admin/models/templates.php +++ b/admin/models/templates.php @@ -451,7 +451,7 @@ class ComponentbuilderModelTemplates extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/models/validation_rules.php b/admin/models/validation_rules.php index 9f83ada48..4b115e329 100644 --- a/admin/models/validation_rules.php +++ b/admin/models/validation_rules.php @@ -361,7 +361,7 @@ class ComponentbuilderModelValidation_rules extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || ComponentbuilderHelper::checkString($_access)) { diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index cb0c5d231..851c9676a 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -2432,11 +2432,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_external_code` ( --- --- Always insure this column rules is large enough for all the access control values. --- -ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control.'; - -- -- Always insure this column name is large enough for long component and view names. -- diff --git a/componentbuilder.xml b/componentbuilder.xml index 9eb3f11e9..2eb98fdb1 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 10th December, 2020 + 11th December, 2020 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/script.php b/script.php index e27fc33a8..9791cda8d 100644 --- a/script.php +++ b/script.php @@ -4281,7 +4281,27 @@ class com_componentbuilderInstallerScript $app->enqueueMessage(JText::_('All related items was removed from the #__assets table')); } - // Check for the biggest rules item in the database at this point + // Get the biggest rule column in the assets table at this point. + $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $db->setQuery($get_rule_length); + if ($db->execute()) + { + $rule_length = $db->loadResult(); + // Check the size of the rules column + if ($rule_length < 5120) + { + // Revert the assets table rules column back to the default + $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + $db->setQuery($revert_rule); + $db->execute(); + $app->enqueueMessage(JText::_('Reverted the #__assets table rules column back to its default size of varchar(5120)')); + } + else + { + + $app->enqueueMessage(JText::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.')); + } + } // Set db if not set already. if (!isset($db)) @@ -6602,6 +6622,22 @@ class com_componentbuilderInstallerScript $db->setQuery($query); $allDone = $db->execute(); + // Get the biggest rule column in the assets table at this point. + $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $db->setQuery($get_rule_length); + if ($db->execute()) + { + $rule_length = $db->loadResult(); + // Check the size of the rules column + if ($rule_length <= 94240) + { + // Fix the assets table rules column size + $fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; + $db->setQuery($fix_rules_size); + $db->execute(); + $app->enqueueMessage(JText::_('The #__assets table rules column was resized to the MEDIUMTEXT datatype for the components possible large permission rules.')); + } + } echo ' ';