diff --git a/Makefile b/Makefile index d24da5591..5d954e9cc 100644 --- a/Makefile +++ b/Makefile @@ -341,6 +341,7 @@ demo: generate-secrets $(MAKE) reindex-fcrepo-metadata ENVIROMENT=demo $(MAKE) reindex-solr ENVIROMENT=demo $(MAKE) reindex-triplestore ENVIROMENT=demo + $(MAKE) fix-masonry $(MAKE) secrets_warning .PHONY: local @@ -505,6 +506,8 @@ set_admin_password: echo "$(PASSWORD)" | $(CMD) secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD >> /dev/null @echo "\ndone." +# Hot fix section. These are not meant to be run normally but are meant to be run when needed. + LATEST_VERSION := $(shell curl -s https://api.github.com/repos/desandro/masonry/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/') .PHONY: fix-masonry @@ -515,3 +518,10 @@ fix-masonry: docker-compose exec drupal bash -lc "[ -d '/var/www/drupal/web/libraries' ] && exit ; mkdir -p /var/www/drupal/web/libraries ; chmod 755 /var/www/drupal/web/libraries ; chown 1000:nginx /var/www/drupal/web/libraries" docker-compose exec drupal bash -lc "cd /var/www/drupal/web/libraries/ ; [ ! -d '/var/www/drupal/web/libraries/masonry' ] && git clone --quiet --branch ${LATEST_VERSION} https://github.com/desandro/masonry.git || echo Ready" docker-compose exec drupal bash -lc "cd /var/www/drupal/web/libraries/ ; [ -d '/var/www/drupal/web/libraries/masonry' ] && chmod -R 755 /var/www/drupal/web/libraries/masonry ; chown -R 1000:nginx /var/www/drupal/web/libraries/masonry" + +.PHONY: fix_views +.SILENT: fix_views +## This fixes a know issues with views when using the make local build. The error must be triggered before this will work. +fix_views: + docker cp scripts/patch_views.sh $$(docker ps --format "{{.Names}}" | grep drupal):/var/www/drupal/patch_views.sh + docker-compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr" \ No newline at end of file diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 7c748bf96..9ad979f63 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -128,3 +128,14 @@ To fix this: * edit your .env file, an increase ALPACA_HOUDINI_TIMEOUT (and other similar timeouts if necessary). Note these values are in milliseconds. * make docker-compose.yml (this is necessary to pick up the change and re-write docker-compose.yml) * restart containers + +## Uncaught PHP Exception InvalidArgumentException or Flysystem driver is missing + +Error message likely to see. +> FastCGI sent in stderr: "PHP message: Uncaught PHP Exception InvalidArgumentException: "A valid cache entry key is required. Use getAll() to get all table data." at /var/www/drupal/web/core/modules/views/src/ViewsData.php line 140" while reading response header from upstream + +A log of the error is needed for the fix to review. A full description of the issue and how the error triggered is on https://github.com/Islandora-Devops/isle-dc/pull/213. + +To fix this: + +* Run `make fix_views` diff --git a/scripts/patch_views.sh b/scripts/patch_views.sh new file mode 100644 index 000000000..5c8bcbe2c --- /dev/null +++ b/scripts/patch_views.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -e + +# To be precise on the error message that matches the error this should address. +ERROR_MESSAGE=$(drush watchdog:show --severity=Error --filter="InvalidArgumentException: A valid cache entry key is required" | awk '{print $6}') + +# If error message equals to "No such file or directory", then exit. +if [[ $ERROR_MESSAGE == *'InvalidArgumentException'* ]]; then + + # Install Drupal Console. + drupal_console_installed() { + composer show 'drupal/console' | grep -q '/var/www/drupal/vendor/drupal/console' + } + if drupal_console_installed; then + echo 'Package installed' + else + composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader -W + fi + + # Reinstall views + enabled_view=`/var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Enabled' | cut -d ' ' -f 2 | tail -n +2` + for dis_view in $enabled_view; do + echo "Disabling view $dis_view" + /var/www/drupal/vendor/drupal/console/bin/drupal views:disable $dis_view + done + + for en_view in $enabled_view; do + echo "Reenabling view $en_view" + /var/www/drupal/vendor/drupal/console/bin/drupal views:enable $en_view + done + + # Install devel. + devel_installed() { + composer show 'drupal/devel' | grep -q '/var/www/drupal/web/modules/contrib/devel' + } + if devel_installed; then + echo 'Package installed' + else + composer require 'drupal/devel:^4.1' -W + fi + drush pm:enable -y devel + + echo -e "\n\nThis will likely throw an error, but that's okay. It's just a patch.\n\n" + { # try + drush dev:reinstall -y islandora + } || { # catch + echo -e "\nIgnore these errors. This will fail if any content is already created.\n\n" + } + + # Clear caches + /var/www/drupal/vendor/drupal/console/bin/drupal cache:rebuild + /var/www/drupal/vendor/drupal/console/bin/drupal cr all + /var/www/drupal/vendor/drupal/console/bin/drupal node:access:rebuild + drush cron +fi