Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstall islandora & views for make local #213

Merged
merged 7 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
11 changes: 11 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
55 changes: 55 additions & 0 deletions scripts/patch_views.sh
Original file line number Diff line number Diff line change
@@ -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