From 838aa1208ba39b7cb482eaa2785ecad22e891075 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 12 Dec 2020 08:24:57 +0200 Subject: [PATCH] Added more compiler messages to give info on how the assets table fix works if needed. --- README.md | 5 +- admin/README.txt | 5 +- admin/helpers/compiler.php | 58 ++++++++++++++++++++- admin/helpers/compiler/a_Get.php | 7 +++ admin/helpers/compiler/e_Interpretation.php | 27 +++++----- componentbuilder.xml | 2 +- 6 files changed, 84 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 737b9dbd6..465b40c9e 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,6 @@ Get involved on the forums, and the GitHub issues, and you can even help us deve TODO ====== -- Add automatic (REST) API ability for all components build with [JCB](http://joomlacomponentbuilder.com). So we can link any component build with JCB to an Android/Apple APP. - Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](http://joomlacomponentbuilder.com). - Team collaborative development across [JCB](http://joomlacomponentbuilder.com) installations offline and online. - Documentation (maintained by the community) for [JCB](http://joomlacomponentbuilder.com). (help us select the best system for this) @@ -144,11 +143,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*: 11th December, 2020 ++ *Last Build*: 12th 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*: **290481** ++ *Line count*: **290479** + *Field count*: **1555** + *File count*: **1923** + *Folder count*: **316** diff --git a/admin/README.txt b/admin/README.txt index 737b9dbd6..465b40c9e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -133,7 +133,6 @@ Get involved on the forums, and the GitHub issues, and you can even help us deve TODO ====== -- Add automatic (REST) API ability for all components build with [JCB](http://joomlacomponentbuilder.com). So we can link any component build with JCB to an Android/Apple APP. - Add automatic unit testing. To nurture pipeline integration for all components build with [JCB](http://joomlacomponentbuilder.com). - Team collaborative development across [JCB](http://joomlacomponentbuilder.com) installations offline and online. - Documentation (maintained by the community) for [JCB](http://joomlacomponentbuilder.com). (help us select the best system for this) @@ -144,11 +143,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*: 11th December, 2020 ++ *Last Build*: 12th 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*: **290481** ++ *Line count*: **290479** + *Field count*: **1555** + *File count*: **1923** + *Folder count*: **316** diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php index abc8c4c5c..43cefb508 100644 --- a/admin/helpers/compiler.php +++ b/admin/helpers/compiler.php @@ -190,13 +190,69 @@ class Compiler extends Infusion { $this->app->enqueueMessage( JText::sprintf( - 'The %s language has %s% translated. Was addeded %s', + 'The %s language has %s% translated. Was added %s', $tag, $percentage, $whyAddedLang ), 'Notice' ); } } } + // set assets table column fix type messages + $message_fix['intelligent'] = JText::_( + 'The intelligent fix only updates the #__assets table\'s column when it detects that it is too small for the worse case. The intelligent fix also only reverse the #__assets table\'s update on uninstall of the component if it detects that no other component needs the rules column to be larger any longer. This options also shows a notice to the end user of all that it does to the #__assets table on installation and uninstalling of the component.' + ); + $message_fix['sql'] = JText::_( + 'The SQL fix updates the #__assets table\'s column size on installation of the component and reverses it back to the Joomla default on uninstall of the component.' + ); + // set assets table rules column notice + if ($this->addAssetsTableFix) + { + $this->app->enqueueMessage( + JText::_('

Assets Table Notice

'), 'Notice' + ); + $asset_table_fix_type = ($this->addAssetsTableFix == 2) + ? 'intelligent' : 'sql'; + $this->app->enqueueMessage( + JText::sprintf( + 'The #__assets table %s fix has been added to this component. %s', + $asset_table_fix_type, + $message_fix[$asset_table_fix_type] + ), 'Notice' + ); + } + // set assets table rules column Warning + elseif ($this->accessSize >= 30) + { + $this->app->enqueueMessage( + JText::_('

Assets Table Warning

'), 'Warning' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'The Joomla #__assets table\'s rules column has to be fixed for this component to work coherently. JCB has detected that in worse case the rules column in the #__assets table may require %s characters, and yet the Joomla default is only varchar(5120). JCB has three option to resolve this issue, first use less permissions in your component, second use the SQL fix, or the intelligent fix. %s %s', + $this->accessWorseCase, $message_fix['intelligent'], + $message_fix['sql'] + ), 'Warning' + ); + } + // set assets table name column warning if not set + if (!$this->addAssetsTableFix && $this->addAssetsTableNameFix) + { + // only add if not already added + if ($this->accessSize < 30) + { + $this->app->enqueueMessage( + JText::_('

Assets Table Warning

'), + 'Warning' + ); + } + $this->app->enqueueMessage( + JText::sprintf( + 'The Joomla #__assets table\'s name column has to be fixed for this component to work correctly. JCB has detected that the #__assets table name column will need to be enlarged because this component\'s own naming convention is larger than varchar(50) which is the Joomla default. JCB has three option to resolve this issue, first shorter names for your component and/or its admin views, second use the SQL fix, or the intelligent fix. %s %s', + $message_fix['intelligent'], + $message_fix['sql'] + ), 'Warning' + ); + } // move the update server into place $this->setUpdateServer(); // set the global counters diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 6c1782b53..30339c415 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -102,6 +102,13 @@ class Get */ public $addAssetsTableFix = 1; + /** + * Assets table worse case + * + * @var int + */ + public $accessWorseCase; + /** * Switch to add assets table name fix * diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 1dece8ffb..35a98d8ab 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -8523,18 +8523,10 @@ class Interpretation extends Fields // check if we should add the intelligent fix treatment for the assets table if ($this->addAssetsTableFix == 2) { - // 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"; + $data_type = ($this->accessWorseCase > 64000) ? "MEDIUMTEXT" : "TEXT"; // the if statement about $rule_length - $codeIF = "\$rule_length <= " . $character_length; + $codeIF = "\$rule_length <= " . $this->accessWorseCase; // fix column size $script = array(); $script[] = $this->_t(5) . "//" . $this->setLine(__LINE__) @@ -10658,7 +10650,7 @@ class Interpretation extends Fields . ' Always insure this column rules is large enough for all the access control values.'; $db .= PHP_EOL . '--'; $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control.';"; + . "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; } // smaller then 400 makes TEXT large enough elseif ($this->addAssetsTableFix == 1) @@ -10672,7 +10664,7 @@ class Interpretation extends Fields . ' Always insure this column rules is large enough for all the access control values.'; $db .= PHP_EOL . '--'; $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control.';"; + . "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';"; } } @@ -27191,6 +27183,17 @@ function vdm_dkim() { // we do not need the fix for this component $this->addAssetsTableFix = 0; } + else + { + // 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 + ); + $this->accessWorseCase = (int) ComponentbuilderHelper::bcmath( + 'mul', $character_length, 8, 0 + ); + } // return the build return $component; diff --git a/componentbuilder.xml b/componentbuilder.xml index 2eb98fdb1..00f992252 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 11th December, 2020 + 12th December, 2020 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com