@@ -115,6 +115,7 @@ public function mainAction(): ResponseInterface
115115
116116 // if search was triggered, get search parameters from POST variables
117117 $ this ->searchParams = $ this ->getParametersSafely ('searchParameter ' );
118+
118119 // if search was triggered by the ListView plugin, get the parameters from GET variables
119120 // replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596
120121 $ listRequestData = GeneralUtility::_GPmerged ('tx_dlf_listview ' );
@@ -130,13 +131,15 @@ public function mainAction(): ResponseInterface
130131 $ GLOBALS ['TSFE ' ]->fe_user ->setKey ('ses ' , 'search ' , $ this ->searchParams );
131132 }
132133
134+ $ this ->searchParams = is_array ($ this ->searchParams ) ? array_filter ($ this ->searchParams , 'strlen ' ) : [];
135+
133136 // sanitize date search input
134- if (! empty ( $ this ->searchParams [ ' dateFrom ' ] ) || ! empty ( $ this ->searchParams [ ' dateTo ' ] )) {
135- if (empty ( $ this ->searchParams [ ' dateFrom ' ] ) && ! empty ( $ this ->searchParams [ ' dateTo ' ] )) {
137+ if (array_key_exists ( ' dateFrom ' , $ this ->searchParams ) || array_key_exists ( ' dateTo ' , $ this ->searchParams )) {
138+ if (! array_key_exists ( ' dateFrom ' , $ this ->searchParams ) && array_key_exists ( ' dateTo ' , $ this ->searchParams )) {
136139 $ this ->searchParams ['dateFrom ' ] = '* ' ;
137140 }
138141
139- if (empty ( $ this ->searchParams [ ' dateTo ' ] ) && ! empty ( $ this ->searchParams [ ' dateFrom ' ] )) {
142+ if (! array_key_exists ( ' dateTo ' , $ this ->searchParams ) && array_key_exists ( ' dateFrom ' , $ this ->searchParams )) {
140143 $ this ->searchParams ['dateTo ' ] = 'NOW ' ;
141144 }
142145
@@ -168,7 +171,7 @@ public function mainAction(): ResponseInterface
168171
169172 // If no search has been executed, no variables have to be prepared.
170173 // An empty form will be shown.
171- if (is_array ( $ this -> searchParams ) && !empty ($ this ->searchParams )) {
174+ if (!empty ($ this ->searchParams )) {
172175 // get all sortable metadata records
173176 $ sortableMetadata = $ this ->metadataRepository ->findByIsSortable (true );
174177
@@ -276,7 +279,7 @@ public function makeFacetsMenuArray(array $facets): array
276279 // Set search query.
277280 $ searchParams = $ this ->searchParams ;
278281 if (
279- (! empty ( $ searchParams [ 'fulltext ' ] ))
282+ (array_key_exists ( 'fulltext ' , $ searchParams ))
280283 || preg_match ('/ ' . $ fields ['fulltext ' ] . ':\((.*)\)/ ' , trim ($ searchParams ['query ' ]), $ matches )
281284 ) {
282285 // If the query already is a fulltext query e.g using the facets
@@ -298,7 +301,7 @@ public function makeFacetsMenuArray(array $facets): array
298301 }
299302
300303 // add filter query for date search
301- if (! empty ( $ this ->searchParams [ ' dateFrom ' ] ) && ! empty ( $ this ->searchParams [ ' dateTo ' ] )) {
304+ if (array_key_exists ( ' dateFrom ' , $ this ->searchParams ) && array_key_exists ( ' dateTo ' , $ this ->searchParams )) {
302305 // combine dateFrom and dateTo into filterquery as range search
303306 $ search ['params ' ]['filterquery ' ][]['query ' ] = '{!join from= ' . $ fields ['uid ' ] . ' to= ' . $ fields ['uid ' ] . '} ' . $ fields ['date ' ] . ':[ ' . $ this ->searchParams ['dateFrom ' ] . ' TO ' . $ this ->searchParams ['dateTo ' ] . '] ' ;
304307 }
@@ -326,7 +329,7 @@ public function makeFacetsMenuArray(array $facets): array
326329 }
327330 }
328331
329- if (isset ( $ this ->searchParams [ ' fq ' ] ) && is_array ($ this ->searchParams ['fq ' ])) {
332+ if (array_key_exists ( ' fq ' , $ this ->searchParams ) && is_array ($ this ->searchParams ['fq ' ])) {
330333 foreach ($ this ->searchParams ['fq ' ] as $ fq ) {
331334 $ search ['params ' ]['filterquery ' ][]['query ' ] = $ fq ;
332335 }
0 commit comments