Added temp workaround for gh-238 to insure component behave correctly with cache enabled on website

This commit is contained in:
Llewellyn van der Merwe 2018-03-03 06:01:21 +02:00
parent 45e1c33865
commit 0c243d75c8
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
4 changed files with 84 additions and 10 deletions

View File

@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.6.17
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **183530**
+ *Line count*: **183567**
+ *Field count*: **1645**
+ *File count*: **1169**
+ *Folder count*: **189**

View File

@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.6.17
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **183530**
+ *Line count*: **183567**
+ *Field count*: **1645**
+ *File count*: **1169**
+ *Folder count*: **189**

View File

@ -38,18 +38,30 @@ jimport('joomla.application.component.controller');
class ###Component###Controller extends JControllerLegacy
{
/**
* display task
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @return void
*/
function display($cachable = false, $urlparams = false)
{
// set default view if not set
$view = $this->input->getCmd('view', '###SITE_DEFAULT_VIEW###');
$this->input->set('view', $view);
$isEdit = $this->checkEditView($view);
$layout = $this->input->get('layout', null, 'WORD');
$id = $this->input->getInt('id');
$cachable = true;
// $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238)
// insure that the view is not cashable if edit view or if user is logged in
$user = JFactory::getUser();
if ($user->get('id') || $isEdit)
{
$cachable = false;
}
// Check for edit form.
if($isEdit)
@ -81,8 +93,33 @@ class ###Component###Controller extends JControllerLegacy
return false;
}
}
// we may need to make this more dynamic in the future. (TODO)
$safeurlparams = array(
'catid' => 'INT',
'id' => 'INT',
'cid' => 'ARRAY',
'year' => 'INT',
'month' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'showall' => 'INT',
'return' => 'BASE64',
'filter' => 'STRING',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'filter-search' => 'STRING',
'print' => 'BOOLEAN',
'lang' => 'CMD',
'Itemid' => 'INT');
return parent::display($cachable, $urlparams);
// should these not merge?
if (###Component###Helper::checkArray($urlparams))
{
$safeurlparams = ###Component###Helper::mergeArrays(array($urlparams, $safeurlparams));
}
return parent::display($cachable, $safeurlparams);
}
protected function checkEditView($view)

View File

@ -35,18 +35,30 @@ jimport('joomla.application.component.controller');
class ComponentbuilderController extends JControllerLegacy
{
/**
* display task
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @return void
*/
function display($cachable = false, $urlparams = false)
{
// set default view if not set
$view = $this->input->getCmd('view', '');
$this->input->set('view', $view);
$isEdit = $this->checkEditView($view);
$layout = $this->input->get('layout', null, 'WORD');
$id = $this->input->getInt('id');
$cachable = true;
// $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238)
// insure that the view is not cashable if edit view or if user is logged in
$user = JFactory::getUser();
if ($user->get('id') || $isEdit)
{
$cachable = false;
}
// Check for edit form.
if($isEdit)
@ -78,8 +90,33 @@ class ComponentbuilderController extends JControllerLegacy
return false;
}
}
// we may need to make this more dynamic in the future. (TODO)
$safeurlparams = array(
'catid' => 'INT',
'id' => 'INT',
'cid' => 'ARRAY',
'year' => 'INT',
'month' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'showall' => 'INT',
'return' => 'BASE64',
'filter' => 'STRING',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'filter-search' => 'STRING',
'print' => 'BOOLEAN',
'lang' => 'CMD',
'Itemid' => 'INT');
return parent::display($cachable, $urlparams);
// should these not merge?
if (ComponentbuilderHelper::checkArray($urlparams))
{
$safeurlparams = ComponentbuilderHelper::mergeArrays(array($urlparams, $safeurlparams));
}
return parent::display($cachable, $safeurlparams);
}
protected function checkEditView($view)