1717use Joomla \Component \Patchtester \Administrator \GithubCredentialsTrait ;
1818use Joomla \Component \Patchtester \Administrator \Helper \Helper ;
1919use Joomla \Database \DatabaseQuery ;
20+ use Joomla \Database \ParameterType ;
2021use RuntimeException ;
2122
2223// phpcs:disable PSR1.Files.SideEffects
@@ -210,20 +211,15 @@ protected function getListQuery()
210211 . ' ON ' . $ db ->quoteName ('tests.pull_id ' ) . ' = '
211212 . $ db ->quoteName ('pulls.pull_id ' )
212213 );
213- $ search = $ this ->getState ()->get ('filter.search ' );
214214
215- if (! empty ( $ search )) {
215+ if ($ search = $ this -> getState ()-> get ( ' filter.search ' )) {
216216 if (stripos ($ search , 'id: ' ) === 0 ) {
217- $ query ->where (
218- $ db ->quoteName ('pulls.pull_id ' ) . ' = ' . (int )substr (
219- $ search ,
220- 3
221- )
222- );
217+ $ search = (int ) substr ($ search , 3 );
218+ $ query ->where ($ db ->quoteName ('pulls.pull_id ' ) . ' = :pullid ' )
219+ ->bind (':pullid ' , $ search );
223220 } elseif (is_numeric ($ search )) {
224- $ query ->where (
225- $ db ->quoteName ('pulls.pull_id ' ) . ' = ' . (int )$ search
226- );
221+ $ query ->where ($ db ->quoteName ('pulls.pull_id ' ) . ' = :pullid ' )
222+ ->bind (':pullid ' , $ search );
227223 } else {
228224 $ query ->where (
229225 '( ' . $ db ->quoteName ('pulls.title ' ) . ' LIKE ' . $ db ->quote (
@@ -234,40 +230,33 @@ protected function getListQuery()
234230 }
235231
236232 $ applied = $ this ->getState ()->get ('filter.applied ' );
237- if (! empty ($ applied )) {
233+ if (is_numeric ($ applied )) {
238234 // Not applied patches have a NULL value, so build our value part of the query based on this
239- $ value = $ applied === 'no ' ? ' IS NULL ' : ' = 1 ' ;
235+ $ value = $ applied === '0 ' ? ' IS NULL ' : ' = 1 ' ;
240236 $ query ->where ($ db ->quoteName ('applied ' ) . $ value );
241237 }
242238
243239 $ branch = $ this ->getState ()->get ('filter.branch ' );
244240 if (!empty ($ branch )) {
245- $ query ->where (
246- $ db ->quoteName ('pulls.branch ' ) . ' IN ( ' . implode (
247- ', ' ,
248- $ db ->quote ($ branch )
249- ) . ') '
250- );
241+ $ query ->whereIn ($ db ->quoteName ('pulls.branch ' ), (array ) $ branch , ParameterType::STRING );
251242 }
252243
253- $ applied = $ this ->getState ()->get ('filter.rtc ' );
254- if (!empty ($ applied )) {
255- // Not applied patches have a NULL value, so build our value part of the query based on this
256- $ value = $ applied === 'no ' ? '0 ' : '1 ' ;
257- $ query ->where ($ db ->quoteName ('pulls.is_rtc ' ) . ' = ' . $ value );
244+ $ rtc = $ this ->getState ()->get ('filter.rtc ' );
245+ if (is_numeric ($ rtc )) {
246+ $ query ->where ($ db ->quoteName ('pulls.is_rtc ' ) . ' = :rtc ' )
247+ ->bind (':rtc ' , $ rtc );
258248 }
259249
260250 $ npm = $ this ->getState ()->get ('filter.npm ' , '' );
261-
262- if ( strlen ( $ npm ) === 1 ) {
263- $ query -> where ( $ db -> quoteName ( ' pulls.is_npm ' ) . ' = ' . ( int ) $ npm );
251+ if ( is_numeric ( $ npm )) {
252+ $ query -> where ( $ db -> quoteName ( ' pulls.is_npm ' ) . ' = :npm ' )
253+ -> bind ( ' :npm ' , $ npm );
264254 }
265255
266256 $ draft = $ this ->getState ()->get ('filter.draft ' );
267- if (!empty ($ draft )) {
268- // Not applied patches have a NULL value, so build our value part of the query based on this
269- $ value = $ draft === 'no ' ? '0 ' : '1 ' ;
270- $ query ->where ($ db ->quoteName ('pulls.is_draft ' ) . ' = ' . $ value );
257+ if (is_numeric ($ draft )) {
258+ $ query ->where ($ db ->quoteName ('pulls.is_draft ' ) . ' = :draft ' )
259+ ->bind (':draft ' , $ draft );
271260 }
272261
273262 $ labels = $ this ->getState ()->get ('filter.label ' );
0 commit comments