Skip to content
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
44 changes: 44 additions & 0 deletions app-hooks/before-starting/90-files-fulltextsearch-dotted-uid.sh
Original file line number Diff line number Diff line change
@@ -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>\([^<]*\)<\/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"
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading