refactor(routing): rewire the setsites ajax route to an extension-free url - #32
Merged
Merged
Conversation
This was referenced Jul 27, 2026
…e url
The route url 'ajax/setsites.php' is prefixed to /apps/external/ajax/setsites.php
by the router, which *is* a real file on disk, and the front controller rewrite
skips those paths:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [PT,E=PATH_INFO:$1]
The web server therefore executes the script directly, without the bootstrap
index.php would have performed, and such a request dies with `Class "OC" not
found` (HTTP 500). The route was unreachable at its own declared url.
This is hardening, not a user-visible bug fix. OC.filePath() unconditionally
injects /index.php/ for non-core app .php files, so the admin panel always
requested the routed /index.php/apps/external/ajax/setsites.php form, which
works. Verified against a pristine owncloud/server:11.0.0-rc2.
The url loses its .php suffix so that it no longer resolves to a file on disk.
The actionInclude() target and the route name are unchanged, so linkToRoute()
callers keep working. The js caller moves from OC.filePath() to
OC.generateUrl(): with a non-.php file name OC.filePath() falls through to the
OC.appswebroots[app] branch and would yield a static url instead of a routed one.
No backwards-compatible .php alias is added - an alias would re-introduce
exactly the shadowed url this change removes.
See owncloud/core#41740 and
owncloud/core#41742 for the same change in core.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
force-pushed
the
fix/rewire-legacy-ajax-routes
branch
from
July 27, 2026 21:33
240b4ed to
188f357
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Hardening, in the same class as owncloud/core#41740 and rewired the same way as
owncloud/core#41742. No user-visible behaviour change — see Impact below.
appinfo/routes.phpdeclaredThe router prefixes app route urls with
/apps/<appid>, so the declared urlbecomes
/apps/external/ajax/setsites.php— which is a real file. The frontcontroller rewrite generated by
\OC\Setup::updateHtaccess()only forwards arequest to
index.phpwhen the requested path does not exist on disk:The web server therefore executes the script directly, without the bootstrap
index.phpwould have performed, and the request dies withClass "OC" not found→ HTTP 500. The route was unreachable at its own declared url.Impact: latent, not a live bug
OC.filePath()unconditionally injects/index.php/for non-core app.phpfiles (
core/js/js.js, thefile.substring(file.length - 3) === 'php' && !isCorebranch), so the admin panel always requested the routed
/index.php/apps/external/ajax/setsites.phpform — which works. Verified againsta pristine
owncloud/server:11.0.0-rc2. The setting is not broken today.The value here is that a route is reachable at the url it declares, and the bug
class cannot resurface if a caller is ever written the obvious way.
What this changes
.phpsuffix so that it no longer resolves to a fileon disk. The
actionInclude()target and the route name are unchanged, solinkToRoute()callers keep working.js/admin.jsmoves fromOC.filePath()toOC.generateUrl(). Simply droppingthe
.phpfrom theOC.filePath()call would not work: with a non-.phpfilename and a non-core app,
OC.filePath()falls through to itsOC.appswebroots[app]branch and yields a static url rather than a routedone.
No backwards-compatible
.phpalias is added — an alias would re-introduceexactly the shadowed url this change removes, so it would be dead on arrival.
Release note
This app needs its own release before an ownCloud bundle picks the change up.
🤖 Generated with Claude Code