From a9498861fa33bf5188b2a4c8f09196195b7585c1 Mon Sep 17 00:00:00 2001 From: Don Richards Date: Thu, 13 Jan 2022 21:55:54 -0500 Subject: [PATCH 1/6] Reinstall islandora & views for make local --- Makefile | 1 + scripts/patch_views.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 scripts/patch_views.sh diff --git a/Makefile b/Makefile index 2ec67a33f..189dd42a1 100644 --- a/Makefile +++ b/Makefile @@ -336,6 +336,7 @@ demo: generate-secrets $(MAKE) reindex-fcrepo-metadata ENVIROMENT=demo $(MAKE) reindex-solr ENVIROMENT=demo $(MAKE) reindex-triplestore ENVIROMENT=demo + $(MAKE) fix-masonry .PHONY: local .SILENT: local diff --git a/scripts/patch_views.sh b/scripts/patch_views.sh new file mode 100644 index 000000000..fb12aacc6 --- /dev/null +++ b/scripts/patch_views.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +# Reinstall views +/var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Enabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' +/var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Disabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' + +# Install devel. +composer require 'drupal/devel:^4.1' -W && drush pm:enable -y devel +drush dev:reinstall islandora + +# 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 From b5756c3bcaa8f828527346b5b0d6c95952aa3639 Mon Sep 17 00:00:00 2001 From: Don Richards Date: Fri, 14 Jan 2022 09:50:12 -0500 Subject: [PATCH 2/6] Move to it's own hot fit command --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 189dd42a1..8e68064c8 100644 --- a/Makefile +++ b/Makefile @@ -471,6 +471,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 @@ -481,3 +483,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 From ee8029439c404c73c275140f2706d8ba7faafb9b Mon Sep 17 00:00:00 2001 From: Don Richards Date: Fri, 14 Jan 2022 09:51:10 -0500 Subject: [PATCH 3/6] Adds check before running & add drupal console here --- scripts/patch_views.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scripts/patch_views.sh b/scripts/patch_views.sh index fb12aacc6..9efc7a036 100644 --- a/scripts/patch_views.sh +++ b/scripts/patch_views.sh @@ -1,16 +1,25 @@ #!/usr/bin/env bash set -e -# Reinstall views -/var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Enabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' -/var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Disabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' +# To be precise on the error message that matches the error this should address. +ERROR_MESSAGE=$(drush watchdog:show --severity=Error | grep 'cron\|php' | grep 'A valid cache entry key is required' | awk '{print $6}') -# Install devel. -composer require 'drupal/devel:^4.1' -W && drush pm:enable -y devel -drush dev:reinstall islandora +# If error message equals to "No such file or directory", then exit. +if [[ $ERROR_MESSAGE == *'InvalidArgumentException'* ]]; then + # Install Drupal Console. + composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader -W -# 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 + # Reinstall views + /var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Enabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' + /var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Disabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' + + # Install devel. + composer require 'drupal/devel:^4.1' -W && drush pm:enable -y devel + drush dev:reinstall islandora + + # 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 From 07017d32479afb9d9456b33241632691424c2207 Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:16:48 -0500 Subject: [PATCH 4/6] Improve queries --- scripts/patch_views.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/patch_views.sh b/scripts/patch_views.sh index 9efc7a036..589bba817 100644 --- a/scripts/patch_views.sh +++ b/scripts/patch_views.sh @@ -2,7 +2,7 @@ set -e # To be precise on the error message that matches the error this should address. -ERROR_MESSAGE=$(drush watchdog:show --severity=Error | grep 'cron\|php' | grep 'A valid cache entry key is required' | awk '{print $6}') +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 @@ -10,8 +10,8 @@ if [[ $ERROR_MESSAGE == *'InvalidArgumentException'* ]]; then composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader -W # Reinstall views - /var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Enabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' - /var/www/drupal/vendor/drupal/console/bin/drupal views:debug | grep Disabled | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' + /var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Enabled' | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' + /var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Disabled' | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' # Install devel. composer require 'drupal/devel:^4.1' -W && drush pm:enable -y devel From 6ed9d76137f8629b8b80c1a2f02f051cd9f5d202 Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:26:36 -0500 Subject: [PATCH 5/6] add fix_view docs --- docs/troubleshooting.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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` From cde0ff8c86a740b377c2700eafb6b07fe814b879 Mon Sep 17 00:00:00 2001 From: Don Richards Date: Thu, 28 Apr 2022 13:00:43 -0400 Subject: [PATCH 6/6] Add currently enabled index to only impact enabled views --- scripts/patch_views.sh | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/scripts/patch_views.sh b/scripts/patch_views.sh index 589bba817..5c8bcbe2c 100644 --- a/scripts/patch_views.sh +++ b/scripts/patch_views.sh @@ -6,16 +6,46 @@ ERROR_MESSAGE=$(drush watchdog:show --severity=Error --filter="InvalidArgumentEx # If error message equals to "No such file or directory", then exit. if [[ $ERROR_MESSAGE == *'InvalidArgumentException'* ]]; then + # Install Drupal Console. - composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader -W + 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 - /var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Enabled' | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:disable " $1)}' - /var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Disabled' | awk '{system("/var/www/drupal/vendor/drupal/console/bin/drupal views:enable " $1)}' + 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. - composer require 'drupal/devel:^4.1' -W && drush pm:enable -y devel - drush dev:reinstall islandora + 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