File tree Expand file tree Collapse file tree 3 files changed +39
-11
lines changed
administrator/components/com_patchtester Expand file tree Collapse file tree 3 files changed +39
-11
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,43 @@ public function purge()
3737 JSession::checkToken () or jexit (JText::_ ('JINVALID_TOKEN ' ));
3838
3939 jimport ('joomla.filesystem.file ' );
40+ jimport ('joomla.filesystem.folder ' );
4041
41- if (file_exists (JPATH_CACHE . '/patchtester.json ' ) && !JFile::delete (JPATH_CACHE . '/patchtester.json ' ))
42+ $ failures = 0 ;
43+ $ successes = 0 ;
44+
45+ $ cacheFiles = JFolder::files (JPATH_CACHE );
46+
47+ foreach ($ cacheFiles as $ file )
48+ {
49+ if (strpos ($ file , 'patchtester-page- ' ) === 0 )
50+ {
51+ if (!JFile::delete (JPATH_CACHE . '/ ' . $ file ))
52+ {
53+ $ failures ++;
54+ }
55+ else
56+ {
57+ $ successes ++;
58+ }
59+ }
60+ }
61+
62+ if ($ failures > 0 )
4263 {
43- $ msg = JText::_ ('COM_PATCHTESTER_PURGE_FAIL ' );
44- $ msgType = 'error ' ;
64+ JFactory::getApplication ()->enqueueMessage (JText::plural ('COM_PATCHTESTER_PURGE_FAIL ' , $ failures ), 'error ' );
4565 }
46- else
66+
67+ if ($ successes > 0 )
68+ {
69+ JFactory::getApplication ()->enqueueMessage (JText::plural ('COM_PATCHTESTER_PURGE_SUCCESS ' , $ successes ), 'message ' );
70+ }
71+
72+ if ($ failures == 0 && $ successes == 0 )
4773 {
48- $ msg = JText::_ ('COM_PATCHTESTER_PURGE_SUCCESS ' );
49- $ msgType = 'message ' ;
74+ JFactory::getApplication ()->enqueueMessage (JText::_ ('COM_PATCHTESTER_PURGE_NA ' ), 'message ' );
5075 }
5176
52- $ this ->setRedirect ('index.php?option=com_patchtester&view=pulls ' , $ msg , $ msgType );
77+ $ this ->setRedirect ('index.php?option=com_patchtester&view=pulls ' );
5378 }
5479}
Original file line number Diff line number Diff line change @@ -34,8 +34,11 @@ COM_PATCHTESTER_NOT_APPLIED="Not Applied"
3434COM_PATCHTESTER_OPEN_IN_GITHUB =" Open in GitHub"
3535COM_PATCHTESTER_OPEN_IN_JOOMLACODE =" Open in JoomlaCode"
3636COM_PATCHTESTER_PURGE_CACHE =" Purge Cache"
37- COM_PATCHTESTER_PURGE_FAIL =" Could not purge the cache"
38- COM_PATCHTESTER_PURGE_SUCCESS =" Cache purged successfully"
37+ COM_PATCHTESTER_PURGE_FAIL =" Purge operation not completed successfully, %s files not removed."
38+ COM_PATCHTESTER_PURGE_FAIL_1 =" Purge operation not completed successfully, %s file not removed."
39+ COM_PATCHTESTER_PURGE_NA =" No cache files to remove."
40+ COM_PATCHTESTER_PURGE_SUCCESS =" Purge operation completed successfully, %s files removed."
41+ COM_PATCHTESTER_PURGE_SUCCESS_1 =" Purge operation completed successfully, %s file removed."
3942COM_PATCHTESTER_REPO_IS_GONE =" The patch could not be applied because the repository is missing"
4043COM_PATCHTESTER_REVERT_OK =" Patch successfully reverted"
4144COM_PATCHTESTER_REVERT_PATCH =" Revert Patch"
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ public function getItems()
167167
168168 try
169169 {
170- $ cacheFile = JPATH_CACHE . '/patchtester.json ' ;
170+ $ cacheFile = JPATH_CACHE . '/patchtester-page- ' . $ this -> getPagination ()-> pagesCurrent . ' .json ' ;
171171 $ params = $ this ->getState ('params ' );
172172
173173 // Check if caching is enabled
@@ -271,7 +271,7 @@ protected function requestFromGithub()
271271 if ($ params ->get ('cache ' ) == 1 )
272272 {
273273 $ data = json_encode ($ pulls );
274- file_put_contents (JPATH_CACHE . '/patchtester.json ' , $ data );
274+ file_put_contents (JPATH_CACHE . '/patchtester-page- ' . $ this -> getPagination ()-> pagesCurrent . ' .json ' , $ data );
275275 }
276276 }
277277 else
You can’t perform that action at this time.
0 commit comments