From faf9b98b11582898fab8428a9e2ec65ec58d01d3 Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Wed, 29 Jun 2016 18:44:39 +0200 Subject: [PATCH] Fix include resolution Incorrect use of += operator on arrays caused the story includes to always be unset --- .../Phrasea/Controller/Api/V1Controller.php | 26 ++++++++++--------- .../Phrasea/Search/RecordTransformer.php | 1 + tests/bootstrap.sh | 4 ++- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 5fa9bbaede..4514e084db 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1407,24 +1407,26 @@ class V1Controller extends Controller */ private function resolveSearchIncludes(Request $request) { - $includes = []; - - if ($request->get('search_type') != SearchEngineOptions::RECORD_STORY) { - $includes += [ - 'results.stories.records.subdefs', - 'results.stories.records.metadata', - 'results.stories.records.caption', - 'results.stories.records.status' - ]; - } + $includes = [ + 'results.stories.records' + ]; if ($request->attributes->get('_extended', false)) { - $includes += [ + if ($request->get('search_type') != SearchEngineOptions::RECORD_STORY) { + $includes = array_merge($includes, [ + 'results.stories.records.subdefs', + 'results.stories.records.metadata', + 'results.stories.records.caption', + 'results.stories.records.status' + ]); + } + + $includes = array_merge($includes, [ 'results.records.subdefs', 'results.records.metadata', 'results.records.caption', 'results.records.status' - ]; + ]); } return $includes; diff --git a/lib/Alchemy/Phrasea/Search/RecordTransformer.php b/lib/Alchemy/Phrasea/Search/RecordTransformer.php index 9fdb3a9847..9d995eedea 100644 --- a/lib/Alchemy/Phrasea/Search/RecordTransformer.php +++ b/lib/Alchemy/Phrasea/Search/RecordTransformer.php @@ -15,6 +15,7 @@ use League\Fractal\TransformerAbstract; class RecordTransformer extends TransformerAbstract { protected $availableIncludes = ['thumbnail', 'technical_informations', 'subdefs', 'metadata', 'status', 'caption']; + protected $defaultIncludes = ['thumbnail', 'technical_informations']; /** diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh index 14330c30f8..d4bcfc5476 100755 --- a/tests/bootstrap.sh +++ b/tests/bootstrap.sh @@ -28,9 +28,11 @@ SET @@global.wait_timeout= 999999; DROP SCHEMA IF EXISTS ab_test;DROP SCHEMA IF EXISTS db_test; CREATE SCHEMA IF NOT EXISTS ab_test;CREATE SCHEMA IF NOT EXISTS db_test; ' + if ! ./bin/developer system:uninstall > /dev/null 2>&1 then - rm -f config/configuration.yml config/configuration-compiled.php + mv config/configuration.yml{,.backup} + rm -f config/configuration-compiled.php fi ./bin/setup system:install --email=test@phraseanet.com --password=test --db-user=root --db-template=en --db-password=toor --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y $VERBOSITY case "$INSTALL_MODE" in