@@ -97,10 +97,10 @@ public function __construct($config = array())
9797 protected function populateState ($ ordering = null , $ direction = null )
9898 {
9999 // Load the filter state.
100- $ search = $ this ->getUserStateFromRequest ($ this ->context . '.filter.search ' , 'filter_search ' );
100+ $ search = $ this ->getUserStateFromRequest ($ this ->context . '.filter.search ' , 'filter_search ' , '' );
101101 $ this ->setState ('filter.search ' , $ search );
102102
103- $ searchId = $ this ->getUserStateFromRequest ($ this ->context . '.filter.searchid ' , 'filter_searchid ' );
103+ $ searchId = $ this ->getUserStateFromRequest ($ this ->context . '.filter.searchid ' , 'filter_searchid ' , '' );
104104 $ this ->setState ('filter.searchid ' , $ searchId );
105105
106106 // Load the parameters.
@@ -167,11 +167,13 @@ public function getItems()
167167
168168 try
169169 {
170- $ cacheFile = JPATH_CACHE . '/patchtester-page- ' . $ this ->getPagination ()->pagesCurrent . '.json ' ;
171- $ params = $ this ->getState ('params ' );
170+ $ cacheFile = JPATH_CACHE . '/patchtester-page- ' . $ this ->getPagination ()->pagesCurrent . '.json ' ;
171+ $ params = $ this ->getState ('params ' );
172+ $ searchId = $ this ->getState ('filter.searchid ' );
173+ $ searchWord = $ this ->getState ('filter.search ' );
172174
173- // Check if caching is enabled
174- if ($ params ->get ('cache ' , 1 ) == 1 )
175+ // Check if caching is enabled or that we aren't filtering
176+ if ($ params ->get ('cache ' , 1 ) == 1 && $ searchId != '' && $ searchWord != '' )
175177 {
176178 // Fetch cache time from component parameters and convert to seconds
177179 $ cacheTime = $ params ->get ('cache_lifetime ' , 60 );
@@ -221,8 +223,17 @@ protected function requestFromGithub()
221223 $ search = $ this ->getState ('filter.search ' );
222224 $ searchId = $ this ->getState ('filter.searchid ' );
223225
224- $ pulls = $ this ->github ->pulls ->getList ($ this ->getState ('github_user ' ), $ this ->getState ('github_repo ' ), 'open ' , $ page );
225- usort ($ pulls , array ($ this , 'sortItems ' ));
226+ // Check if we're searching for a single PR
227+ if ($ searchId != '' && $ search == '' )
228+ {
229+ $ pulls = array ();
230+ $ pulls [0 ] = $ this ->github ->pulls ->get ($ this ->getState ('github_user ' ), $ this ->getState ('github_repo ' ), $ searchId );
231+ }
232+ else
233+ {
234+ $ pulls = $ this ->github ->pulls ->getList ($ this ->getState ('github_user ' ), $ this ->getState ('github_repo ' ), 'open ' , $ page );
235+ usort ($ pulls , array ($ this , 'sortItems ' ));
236+ }
226237
227238 foreach ($ pulls as $ i => &$ pull )
228239 {
@@ -232,12 +243,6 @@ protected function requestFromGithub()
232243 continue ;
233244 }
234245
235- if ($ searchId && $ pull ->number != $ searchId )
236- {
237- unset($ pulls [$ i ]);
238- continue ;
239- }
240-
241246 // Try to find a Joomlacode issue number
242247 $ pulls [$ i ]->joomlacode_issue = 0 ;
243248
@@ -268,7 +273,7 @@ protected function requestFromGithub()
268273 // If caching is enabled, save the request data
269274 $ params = $ this ->getState ('params ' );
270275
271- if ($ params ->get ('cache ' ) == 1 )
276+ if ($ params ->get ('cache ' , 1 ) == 1 && $ searchId != '' && $ search != '' )
272277 {
273278 $ data = json_encode ($ pulls );
274279 file_put_contents (JPATH_CACHE . '/patchtester-page- ' . $ this ->getPagination ()->pagesCurrent . '.json ' , $ data );
0 commit comments