From 2e0c4c4369e9e6272802b93d9ac4a86aaf77783a Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Fri, 23 Oct 2026 20:46:59 -0300 Subject: [PATCH] fix: apply temporary files full-text search dotted UID patch on startup Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .../90-files-fulltextsearch-dotted-uid.sh | 44 +++++++++++++++++++ .../files-fulltextsearch-dotted-uid.patch | 5 +++ docs/deployment.md | 6 +++ 3 files changed, 55 insertions(+) create mode 100755 app-hooks/before-starting/90-files-fulltextsearch-dotted-uid.sh create mode 100644 app-hooks/before-starting/files-fulltextsearch-dotted-uid.patch diff --git a/app-hooks/before-starting/90-files-fulltextsearch-dotted-uid.sh b/app-hooks/before-starting/90-files-fulltextsearch-dotted-uid.sh new file mode 100755 index 0000000..f33f31f --- /dev/null +++ b/app-hooks/before-starting/90-files-fulltextsearch-dotted-uid.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Temporary workaround for https://github.com/nextcloud/files_fulltextsearch/issues/389 +# Remove when the fix is released upstream for Nextcloud 35. +set -eu + +app_dir=/var/www/html/custom_apps/files_fulltextsearch +source_file="$app_dir/lib/Service/SearchService.php" +patch_file="$(dirname "$0")/files-fulltextsearch-dotted-uid.patch" + +# Apps installed through the App Store are not necessarily present during setup. +[ -f "$source_file" ] && [ -f "$app_dir/appinfo/info.xml" ] || exit 0 + +version=$(sed -n 's/.*\([^<]*\)<\/version>.*/\1/p' "$app_dir/appinfo/info.xml" | head -n 1) +case "$version" in + 35.*) ;; + *) exit 0 ;; +esac + +fixed='$userId = $searchResult->getRequest()->getAuthor();' +broken='$userId = $this->filesService->secureUsername($searchResult->getRequest()->getAuthor());' + +if grep -Fq "$fixed" "$source_file"; then + echo "files_fulltextsearch: dotted-UID fix already present" + exit 0 +fi + +if ! grep -Fq "$broken" "$source_file"; then + echo "WARNING: files_fulltextsearch $version changed; review dotted-UID fix" >&2 + exit 0 +fi + +if ! patch --batch --fuzz=0 --dry-run -p1 -d "$app_dir" < "$patch_file" >/dev/null; then + echo "WARNING: files_fulltextsearch dotted-UID patch does not apply; keeping Nextcloud available" >&2 + exit 0 +fi + +patch --batch --fuzz=0 -p1 -d "$app_dir" < "$patch_file" +if ! php -l "$source_file" >/dev/null; then + patch --batch --fuzz=0 -R -p1 -d "$app_dir" < "$patch_file" + echo "WARNING: files_fulltextsearch patch failed PHP syntax check; reverted" >&2 + exit 0 +fi + +echo "files_fulltextsearch $version: applied temporary dotted-UID fix" diff --git a/app-hooks/before-starting/files-fulltextsearch-dotted-uid.patch b/app-hooks/before-starting/files-fulltextsearch-dotted-uid.patch new file mode 100644 index 0000000..4c183e3 --- /dev/null +++ b/app-hooks/before-starting/files-fulltextsearch-dotted-uid.patch @@ -0,0 +1,5 @@ +--- a/lib/Service/SearchService.php ++++ b/lib/Service/SearchService.php +@@ -95 +95 @@ +- $userId = $this->filesService->secureUsername($searchResult->getRequest()->getAuthor()); ++ $userId = $searchResult->getRequest()->getAuthor(); diff --git a/docs/deployment.md b/docs/deployment.md index a752417..17b4547 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -109,6 +109,12 @@ services: PHP-FPM pool settings can also be mounted into `/usr/local/etc/php-fpm.d/`. Keep changes compatible with the underlying Nextcloud PHP version and workload. +## Temporary Full Text Search fix for dotted UIDs (Nextcloud 35) + +The before-starting hook applies the upstream [files_fulltextsearch dotted-UID fix](https://github.com/nextcloud/files_fulltextsearch/issues/389) to affected 35.x app installations. It is safe to run again and skips the app if the fix is already present. + +An App Store update performed while Nextcloud is running does **not** invoke this hook. Restart the application container after such updates so that the fix is reapplied if still required. Remove this workaround when the official app includes the correction. + ## Logs and troubleshooting ```bash