diff --git a/composer-deploy.sh b/composer-deploy.sh new file mode 100755 index 0000000..8463b61 --- /dev/null +++ b/composer-deploy.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# This script has to be used when installing dependencies for deployment. +# It makes that symfony/cache is not installed as dependency. symfony/cache is +# already installed with CiviCRM. Depending on the CiviCRM version it results in +# this error when symfony/cache 6 and psr/cache 3 are installed: +# PHP Fatal error: Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): Symfony\Component\ErrorHandler\DebugClassLoader +# must be compatible with Psr\Cache\CacheItemInterface::expiresAt($expiration) + +# In case this extension is actually installed as composer dependency it must +# not replace symfony/cache because it would prevent its installation. + +sed -e 's#^\}#,"replace":{"symfony/cache":"*"}}#' -i composer.json +composer "$@" +code=$? +sed -e 's#,"replace":.*#}#' -i composer.json + +exit $code diff --git a/composer.json b/composer.json index 68a8137..ed99523 100644 --- a/composer.json +++ b/composer.json @@ -46,9 +46,7 @@ ] }, "require-dev": { + "psr/simple-cache": "^1 || ^2 || ^3", "symfony/event-dispatcher-contracts": "^1 || ^2 || ^3" - }, - "conflict": { - "symfony/cache": ">=6" } } diff --git a/composer.json.md b/composer.json.md deleted file mode 100644 index 31e3dc5..0000000 --- a/composer.json.md +++ /dev/null @@ -1,10 +0,0 @@ -# Notes for comments.json - -Because comments are not allowed in JSON this file is used. - -`"symfony/cache": ">=6"` is part of the conflict section to avoid this error: - -> PHP Fatal error: Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): Symfony\Component\ErrorHandler\DebugClassLoader -> must be compatible with Psr\Cache\CacheItemInterface::expiresAt($expiration) - -The code of this extension itself doesn't require `symfony/cache`. \ No newline at end of file diff --git a/tests/docker-prepare.sh b/tests/docker-prepare.sh index 3b83b0e..e68ca52 100755 --- a/tests/docker-prepare.sh +++ b/tests/docker-prepare.sh @@ -40,5 +40,5 @@ else fi cd "$EXT_DIR" -composer update --no-progress --prefer-dist --optimize-autoloader --no-dev +./composer-deploy.sh update --no-progress --prefer-dist --optimize-autoloader --no-dev composer composer-phpunit -- update --no-progress --prefer-dist