mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-23 03:19:00 +00:00
Modify cache mechanism to re-enable pagination (Fix #3)
This commit is contained in:
parent
22860bbe28
commit
3814e12e41
@ -37,18 +37,43 @@ class PatchTesterController extends JControllerLegacy
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
jimport('joomla.filesystem.file');
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
if (file_exists(JPATH_CACHE . '/patchtester.json') && !JFile::delete(JPATH_CACHE . '/patchtester.json'))
|
||||
$failures = 0;
|
||||
$successes = 0;
|
||||
|
||||
$cacheFiles = JFolder::files(JPATH_CACHE);
|
||||
|
||||
foreach ($cacheFiles as $file)
|
||||
{
|
||||
$msg = JText::_('COM_PATCHTESTER_PURGE_FAIL');
|
||||
$msgType = 'error';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = JText::_('COM_PATCHTESTER_PURGE_SUCCESS');
|
||||
$msgType = 'message';
|
||||
if (strpos($file, 'patchtester-page-') === 0)
|
||||
{
|
||||
if (!JFile::delete(JPATH_CACHE . '/' . $file))
|
||||
{
|
||||
$failures++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$successes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_patchtester&view=pulls', $msg, $msgType);
|
||||
if ($failures > 0)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_FAIL', $failures), 'error');
|
||||
}
|
||||
|
||||
if ($successes > 0)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_SUCCESS', $successes), 'message');
|
||||
}
|
||||
|
||||
if ($failures == 0 && $successes == 0)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('COM_PATCHTESTER_PURGE_NA'), 'message');
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_patchtester&view=pulls');
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,11 @@ COM_PATCHTESTER_NOT_APPLIED="Not Applied"
|
||||
COM_PATCHTESTER_OPEN_IN_GITHUB="Open in GitHub"
|
||||
COM_PATCHTESTER_OPEN_IN_JOOMLACODE="Open in JoomlaCode"
|
||||
COM_PATCHTESTER_PURGE_CACHE="Purge Cache"
|
||||
COM_PATCHTESTER_PURGE_FAIL="Could not purge the cache"
|
||||
COM_PATCHTESTER_PURGE_SUCCESS="Cache purged successfully"
|
||||
COM_PATCHTESTER_PURGE_FAIL="Purge operation not completed successfully, %s files not removed."
|
||||
COM_PATCHTESTER_PURGE_FAIL_1="Purge operation not completed successfully, %s file not removed."
|
||||
COM_PATCHTESTER_PURGE_NA="No cache files to remove."
|
||||
COM_PATCHTESTER_PURGE_SUCCESS="Purge operation completed successfully, %s files removed."
|
||||
COM_PATCHTESTER_PURGE_SUCCESS_1="Purge operation completed successfully, %s file removed."
|
||||
COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing"
|
||||
COM_PATCHTESTER_REVERT_OK="Patch successfully reverted"
|
||||
COM_PATCHTESTER_REVERT_PATCH="Revert Patch"
|
||||
|
@ -167,7 +167,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
|
||||
try
|
||||
{
|
||||
$cacheFile = JPATH_CACHE . '/patchtester.json';
|
||||
$cacheFile = JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json';
|
||||
$params = $this->getState('params');
|
||||
|
||||
// Check if caching is enabled
|
||||
@ -271,7 +271,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
if ($params->get('cache') == 1)
|
||||
{
|
||||
$data = json_encode($pulls);
|
||||
file_put_contents(JPATH_CACHE . '/patchtester.json', $data);
|
||||
file_put_contents(JPATH_CACHE . '/patchtester-page-' . $this->getPagination()->pagesCurrent . '.json', $data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user