Files
nextcloud-server-mirror/build/autoloaderchecker.sh
skjnldsv ae4c1065d0 feat(viewer): keep the legacy viewer API in apps/viewer until 39
Dropping the bundled app takes the OCA.Viewer global and the LoadViewer
event with it, and apps in the wild still use both: text and
recommendations ask the global what it can open, photos opens and closes
it, files_pdfviewer re-opens the current file with another handler, and
photos, maps and collectives construct the event without checking that
it exists, so their pages would fail on the missing class.

The global goes back on the page, backed by the package rather than by
the app. open() takes the paths and the loose file info apps passed
before and turns them into nodes, the getters answer from what the last
open() was given, and mimetypes answers by asking the handlers about a
file of that type. registerHandler is deliberately not here: it was
deprecated in the viewer app in August 2025 and this is where it stops.
The event stays as an empty class nobody dispatches.

Both live in apps/viewer, which is not an app: it has no appinfo, the
server autoloads the event from it and the core viewer init script
imports the bridge. The checkers that take every folder in apps/ for an
app are told so: .noopenapi, the untranslated list, and a skip in the
autoloader checker and in tests/enable_all.php for folders without an
appinfo/info.xml. psalm lints it like the others.

Every use of the global logs a warning naming the replacement and
Nextcloud 39, where the folder and those exceptions go.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
2026-10-01 15:21:14 +02:00

84 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
COMPOSER_COMMAND="php composer.phar"
if [ -e "composer.phar" ]
then
echo "Composer found: checking for update"
$COMPOSER_COMMAND self-update
else
echo "Composer not found: fetching"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --2
php -r "unlink('composer-setup.php');"
fi
COMPOSER_VERSION=$($COMPOSER_COMMAND --version | cut -d" " -f3)
COMPOSER_MAJOR_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f1)
COMPOSER_MINOR_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f2)
COMPOSER_PATCH_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f3)
if ! [ "$COMPOSER_MAJOR_VERSION" -gt 2 -o \( "$COMPOSER_MAJOR_VERSION" -eq 2 -a "$COMPOSER_MINOR_VERSION" -ge 10 \) -o \( "$COMPOSER_MAJOR_VERSION" -eq 2 -a "$COMPOSER_MINOR_VERSION" -eq 9 -a "$COMPOSER_PATCH_VERSION" -ge 2 \) ]; then
echo "composer version >= 2.9.2 required. Version found: $COMPOSER_VERSION" >&2
exit 1
fi
REPODIR=`git rev-parse --show-toplevel`
#Redump the main autoloader
echo
echo "Regenerating main autoloader"
$COMPOSER_COMMAND dump-autoload -d $REPODIR
FOUND_COMPOSER_BIN=$(grep --recursive --fixed-strings 'Bamarni\\Composer\\Bin' $REPODIR/lib/composer/composer/)
if [ -n "$FOUND_COMPOSER_BIN" ]; then
echo "The main autoloader contains the composer bin plugin"
echo "Run composer again with --no-dev and commit the result"
exit 1
fi
for app in ${REPODIR}/apps/*; do
if git check-ignore ${app} -q ; then
echo
echo "${app} is not shipped. Ignoring autoloader regeneration"
continue
fi
# apps/viewer is not an app and has no autoloader of its own, the server's covers it
if [[ -d $app && -f $app/appinfo/info.xml ]]; then
echo
echo "Regenerating composer files for ${app}"
$COMPOSER_COMMAND i --no-dev -d ${app}/composer || exit 1
$COMPOSER_COMMAND dump-autoload -d ${app}/composer || exit 1
git checkout ${app}/composer/composer/installed.php
fi
done
files=`git diff --name-only`
composerfile=false
for file in $files
do
if [[ $file == *autoload_classmap* ]]
then
composerfile=true
break
fi
done
rm composer.phar
echo
if [ $composerfile = true ]
then
echo "The autoloaders are not up to date"
echo "Please run: bash build/autoloaderchecker.sh"
echo "And commit the result"
exit 1
else
echo "Autoloader up to date. Carry on"
exit 0
fi