Skip to content

Commit b8f4f6c

Browse files
committed
Merge branch 'dev' into t/jira-1829
2 parents 31e3222 + 221ff63 commit b8f4f6c

7 files changed

Lines changed: 76 additions & 58 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77
name: Tests with PHP ${{ matrix.php-version }}
88
runs-on: ubuntu-latest
99
env:
10-
VUFIND_HOME: $GITHUB_WORKSPACE
11-
VUFIND_LOCAL_DIR: $GITHUB_WORKSPACE/local
10+
VUFIND_HOME: ${{ github.workspace }}
11+
VUFIND_LOCAL_DIR: ${{ github.workspace }}/local
1212
strategy:
1313
matrix:
1414
php-version: ['8.2', '8.3', '8.4']

module/VuFind/src/VuFind/Auth/OpenIDConnect.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,11 @@ protected function validateIssuer(string $iss): bool
549549
*/
550550
protected function verifyJwtClaims(object $claims): bool
551551
{
552+
$clientId = $this->getConfig('client_id');
553+
$audValid = in_array($clientId, (array)($claims->aud ?? []), true);
554+
552555
return (!isset($claims->nonce) || $claims->nonce === $this->session->oidc_nonce)
553-
&& ($claims->aud === $this->getConfig('client_id'))
556+
&& $audValid
554557
&& (!isset($claims->exp) || (is_int($claims->exp) && ($claims->exp > time())));
555558
}
556559

module/VuFind/src/VuFind/View/Helper/Root/Section.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function render(array $context = []): string
159159
} else {
160160
// Default to class-based template.
161161
$template = $this->defaultTemplateDir . '/%s.phtml';
162-
$className = strtolower($this->section::class);
162+
$className = $this->section::class;
163163
return $this->renderClassTemplate($template, $className, $mergedContext);
164164
}
165165
}

module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ public function build(AbstractQuery $query, ?ParamBag $params = null)
149149
} else {
150150
// Clone the query to avoid modifying the original user-visible query
151151
$finalQuery = clone $query;
152-
$finalQuery->setString($this->getNormalizedQueryString($query));
152+
$queryString = $query->getString();
153+
if ($handler = $this->getSearchHandler($query->getHandler(), $queryString)) {
154+
$queryString = $handler->preprocessQueryString($queryString);
155+
}
156+
$finalQuery->setString($this->getNormalizedQueryString($queryString));
153157
}
154158
$string = $finalQuery->getString() ?: '*:*';
155159

@@ -494,7 +498,7 @@ function ($s) {
494498
$searchString = '(*:* NOT ' . $searchString . ')';
495499
}
496500
} else {
497-
$searchString = $this->getNormalizedQueryString($component);
501+
$searchString = $this->getNormalizedQueryString($component->getString());
498502
$searchHandler = $this->getSearchHandler(
499503
$component->getHandler(),
500504
$searchString
@@ -568,18 +572,14 @@ protected function fixTrailingQuestionMarks($string)
568572
}
569573

570574
/**
571-
* Given a Query object, return a fully normalized version of the query string.
575+
* Given a Query string, return a fully normalized version.
572576
*
573-
* @param Query $query Query object
577+
* @param string $queryString Query string
574578
*
575579
* @return string
576580
*/
577-
protected function getNormalizedQueryString($query)
581+
protected function getNormalizedQueryString($queryString)
578582
{
579-
$queryString = $query->getString();
580-
if ($handler = $this->getSearchHandler($query->getHandler(), $queryString)) {
581-
$queryString = $handler->preprocessQueryString($queryString);
582-
}
583583
return $this->fixTrailingQuestionMarks(
584584
$this->getLuceneHelper()->normalizeSearchString(
585585
$queryString

module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testNormalization(string $input, string $output): void
114114
*
115115
* @return array
116116
*/
117-
protected function getQuestionTests()
117+
protected function getQuestionTests(): array
118118
{
119119
// Format: [input, expected output, flags array]
120120
return [
@@ -153,7 +153,7 @@ protected function getQuestionTests()
153153
*
154154
* @return void
155155
*/
156-
protected function runBasicQuestionTest($qb, $handler, $test)
156+
protected function runBasicQuestionTest(QueryBuilder $qb, string $handler, array $test): void
157157
{
158158
[$input, $output, $flags] = $test;
159159
if (
@@ -185,7 +185,7 @@ protected function runBasicQuestionTest($qb, $handler, $test)
185185
*
186186
* @return void
187187
*/
188-
protected function runAdvancedQuestionTest($qb, $handler, $test)
188+
protected function runAdvancedQuestionTest(QueryBuilder $qb, string $handler, array $test): void
189189
{
190190
[$input, $output, $flags] = $test;
191191
if (
@@ -213,7 +213,7 @@ protected function runAdvancedQuestionTest($qb, $handler, $test)
213213
*
214214
* @return void
215215
*/
216-
protected function runQuestionTests($builderParams, $handler)
216+
protected function runQuestionTests(array $builderParams, string $handler): void
217217
{
218218
// Set up an array of expected inputs and outputs:
219219
$tests = $this->getQuestionTests();
@@ -229,7 +229,7 @@ protected function runQuestionTests($builderParams, $handler)
229229
*
230230
* @return void
231231
*/
232-
public function testQueryHandler()
232+
public function testQueryHandler(): void
233233
{
234234
$this->runQuestionTests(
235235
[
@@ -244,7 +244,7 @@ public function testQueryHandler()
244244
*
245245
* @return void
246246
*/
247-
public function testQueryHandlerWithDismax()
247+
public function testQueryHandlerWithDismax(): void
248248
{
249249
$this->runQuestionTests(
250250
[
@@ -259,7 +259,7 @@ public function testQueryHandlerWithDismax()
259259
*
260260
* @return void
261261
*/
262-
public function testQueryHandlerWithEdismax()
262+
public function testQueryHandlerWithEdismax(): void
263263
{
264264
$this->runQuestionTests(
265265
[
@@ -275,7 +275,7 @@ public function testQueryHandlerWithEdismax()
275275
*
276276
* @return void
277277
*/
278-
public function testExactQueryHandler()
278+
public function testExactQueryHandler(): void
279279
{
280280
$qb = new QueryBuilder(
281281
[
@@ -306,7 +306,7 @@ public function testExactQueryHandler()
306306
*
307307
* @return void
308308
*/
309-
public function testQueryHandlerWithFilterQueryAndDisMax()
309+
public function testQueryHandlerWithFilterQueryAndDisMax(): void
310310
{
311311
$qb = new QueryBuilder(
312312
[
@@ -324,7 +324,7 @@ public function testQueryHandlerWithFilterQueryAndDisMax()
324324
*
325325
* @return void
326326
*/
327-
public function testQueryHandlerWithFilterQueryAndNoDisMax()
327+
public function testQueryHandlerWithFilterQueryAndNoDisMax(): void
328328
{
329329
$qb = new QueryBuilder(
330330
[
@@ -343,7 +343,7 @@ public function testQueryHandlerWithFilterQueryAndNoDisMax()
343343
*
344344
* @return void
345345
*/
346-
public function testMatchAllQueryWithFilterQueryAndNoDisMax()
346+
public function testMatchAllQueryWithFilterQueryAndNoDisMax(): void
347347
{
348348
$qb = new QueryBuilder(
349349
[
@@ -364,7 +364,7 @@ public function testMatchAllQueryWithFilterQueryAndNoDisMax()
364364
*
365365
* @return void
366366
*/
367-
public function testHlQ()
367+
public function testHlQ(): void
368368
{
369369
$qb = new QueryBuilder(
370370
[
@@ -391,7 +391,7 @@ public function testHlQ()
391391
*
392392
* @return void
393393
*/
394-
public function testSetFieldsToHighlight()
394+
public function testSetFieldsToHighlight(): void
395395
{
396396
$qb = new QueryBuilder(
397397
[
@@ -432,7 +432,7 @@ public function testSetFieldsToHighlight()
432432
*
433433
* @return void
434434
*/
435-
public function testSetCreateSpellingQuery()
435+
public function testSetCreateSpellingQuery(): void
436436
{
437437
$qb = new QueryBuilder(
438438
[
@@ -463,7 +463,7 @@ public function testSetCreateSpellingQuery()
463463
*
464464
* @return void
465465
*/
466-
public function testQueryGroup()
466+
public function testQueryGroup(): void
467467
{
468468
$qb = new QueryBuilder(
469469
[
@@ -494,7 +494,7 @@ public function testQueryGroup()
494494
*
495495
* @return void
496496
*/
497-
public function testQueryGroupWithAdvancedSyntax()
497+
public function testQueryGroupWithAdvancedSyntax(): void
498498
{
499499
$qb = new QueryBuilder(
500500
[
@@ -529,7 +529,7 @@ public function testQueryGroupWithAdvancedSyntax()
529529
*
530530
* @return void
531531
*/
532-
public function testMultipleQuotedPhrases()
532+
public function testMultipleQuotedPhrases(): void
533533
{
534534
$qb = new QueryBuilder(
535535
[
@@ -553,7 +553,7 @@ public function testMultipleQuotedPhrases()
553553
*
554554
* @return void
555555
*/
556-
public function testMixedQuotedPhrases()
556+
public function testMixedQuotedPhrases(): void
557557
{
558558
$qb = new QueryBuilder(
559559
[
@@ -577,7 +577,7 @@ public function testMixedQuotedPhrases()
577577
*
578578
* @return void
579579
*/
580-
public function testMixedQuotedPhrasesWithEscapedQuote()
580+
public function testMixedQuotedPhrasesWithEscapedQuote(): void
581581
{
582582
$qb = new QueryBuilder(
583583
[
@@ -599,9 +599,9 @@ public function testMixedQuotedPhrasesWithEscapedQuote()
599599
/**
600600
* Data provider for testIndividualQueryHandlerWithGlobalExtraParams().
601601
*
602-
* @return \Iterator
602+
* @return Iterator
603603
*/
604-
public static function globalExtraParamsIndividualQueryDataProvider(): \Iterator
604+
public static function globalExtraParamsIndividualQueryDataProvider(): Iterator
605605
{
606606
yield 'Single value, no extra params' => [
607607
'globalExtraParams' => null,
@@ -773,18 +773,18 @@ public static function globalExtraParamsIndividualQueryDataProvider(): \Iterator
773773
/**
774774
* Test generation with GlobalExtraParams using individual queries.
775775
*
776-
* @param array $globalExtraParams Global extra parameters
777-
* @param array $expected1 First set of expected fields
778-
* @param array $expected2 Second set of expected fields
776+
* @param ?array $globalExtraParams Global extra parameters
777+
* @param array $expected1 First set of expected fields
778+
* @param array $expected2 Second set of expected fields
779779
*
780780
* @return void
781781
*/
782782
#[\PHPUnit\Framework\Attributes\DataProvider('globalExtraParamsIndividualQueryDataProvider')]
783783
public function testIndividualQueryHandlerWithGlobalExtraParams(
784-
$globalExtraParams,
785-
$expected1,
786-
$expected2
787-
) {
784+
?array $globalExtraParams,
785+
array $expected1,
786+
array $expected2
787+
): void {
788788
$q1 = new Query('q', 'test');
789789
$params1 = new ParamBag(['sort' => 'score desc']);
790790
$q2 = new Query('q', 'test2');
@@ -826,9 +826,9 @@ public function testIndividualQueryHandlerWithGlobalExtraParams(
826826
/**
827827
* Data provider for testGroupedQueryHandlerWithGlobalExtraParams().
828828
*
829-
* @return \Iterator
829+
* @return Iterator
830830
*/
831-
public static function globalExtraParamsGroupedQueryDataProvider(): \Iterator
831+
public static function globalExtraParamsGroupedQueryDataProvider(): Iterator
832832
{
833833
yield 'Search type in [test]' => [
834834
'globalExtraParams' => [
@@ -906,9 +906,9 @@ public static function globalExtraParamsGroupedQueryDataProvider(): \Iterator
906906
*/
907907
#[\PHPUnit\Framework\Attributes\DataProvider('globalExtraParamsGroupedQueryDataProvider')]
908908
public function testGroupedQueryHandlerWithGlobalExtraParams(
909-
$globalExtraParams,
910-
$expectedFields
911-
) {
909+
array $globalExtraParams,
910+
array $expectedFields
911+
): void {
912912
$q1 = new Query('q', 'test');
913913
$q2 = new Query('q', 'test2');
914914
$group = new QueryGroup('AND', [$q1, $q2]);
@@ -940,7 +940,7 @@ public function testGroupedQueryHandlerWithGlobalExtraParams(
940940
*
941941
* @return void
942942
*/
943-
public function testNegatedQuery()
943+
public function testNegatedQuery(): void
944944
{
945945
$group = new QueryGroup('NOT', [new Query('q')]);
946946
$qb = new QueryBuilder([]);
@@ -953,7 +953,7 @@ public function testNegatedQuery()
953953
*
954954
* @return void
955955
*/
956-
public function testNegatedAndQuery()
956+
public function testNegatedAndQuery(): void
957957
{
958958
$subgroup1 = new QueryGroup('NOT', [new Query('q1'), new Query('q2')]);
959959
$subgroup2 = new QueryGroup('AND', [new Query('q3'), new Query('q4')]);
@@ -971,7 +971,7 @@ public function testNegatedAndQuery()
971971
*
972972
* @return void
973973
*/
974-
public function testNegatedOrQuery()
974+
public function testNegatedOrQuery(): void
975975
{
976976
$subgroup1 = new QueryGroup('NOT', [new Query('q1'), new Query('q2')]);
977977
$subgroup2 = new QueryGroup('AND', [new Query('q3'), new Query('q4')]);
@@ -989,7 +989,7 @@ public function testNegatedOrQuery()
989989
*
990990
* @return void
991991
*/
992-
public function testDismaxMunge()
992+
public function testDismaxMunge(): void
993993
{
994994
// Set up an array of expected inputs and outputs:
995995
$tests = [
@@ -1021,7 +1021,12 @@ public function testDismaxMunge()
10211021
}
10221022
}
10231023

1024-
public function testDismaxMungeQueryGroupOnlyOnce()
1024+
/**
1025+
* Test that dismax munge is only applied once in query group.
1026+
*
1027+
* @return void
1028+
*/
1029+
public function testDismaxMungeQueryGroupOnlyOnce(): void
10251030
{
10261031
$specs = [
10271032
'test' => [
@@ -1033,11 +1038,12 @@ public function testDismaxMungeQueryGroupOnlyOnce()
10331038
];
10341039
$qb = new QueryBuilder($specs);
10351040
$query = new QueryGroup(
1036-
'AND', [ new Query('some-coded-value', 'test') ]
1041+
'AND',
1042+
[ new Query('some-coded-value', 'test') ]
10371043
);
10381044
$response = $qb->build($query);
10391045
$processedQ = $response->get('q');
1040-
$this->assertEquals(1, preg_match('/\}22@some-coded-value"/', $processedQ[0]));
1041-
$this->assertEquals(0, preg_match('/\}22@22@some-coded-value"/', $processedQ[0]));
1046+
$this->assertMatchesRegularExpression('/\}22@some-coded-value"/', $processedQ[0]);
1047+
$this->assertDoesNotMatchRegularExpression('/\}22@22@some-coded-value"/', $processedQ[0]);
10421048
}
10431049
}

package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)