fix(prefs): resolve autoloader via composer proxy globals#10
Merged
Merged
Conversation
bin/horde-prefs computes the path to vendor/autoload.php using a fixed relative depth from __DIR__. When horde/prefs is installed as a symlink to a git checkout (composer "path" repository, as used in git developer installs), PHP resolves __DIR__ through the symlink target, breaking the fixed-depth assumption and causing the script to fail with "Neither Composer nor PEAR Horde_Autoloader_Default available" even though a valid autoloader exists. The composer-generated bin proxy already computes the correct path via $GLOBALS['_composer_autoload_path'] before including this script. Use it when available, falling back to the existing depth-based paths unchanged for PEAR installs or direct invocation outside the proxy.
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.
bin/horde-prefs computes the path to vendor/autoload.php using a fixed relative
depth from DIR. When horde/prefs is installed as a symlink to a git checkout
(composer "path" repository, as used in git developer installs), PHP resolves
DIR through the symlink target, breaking the fixed-depth assumption and causing
the script to fail with "Neither Composer nor PEAR Horde_Autoloader_Default
available" even though a valid autoloader exists.
The composer-generated bin proxy already computes the correct path via
$GLOBALS['_composer_autoload_path'] before including this script. Use it when
available, falling back to the existing depth-based paths unchanged for PEAR
installs or direct invocation outside the proxy.
Reproduced and verified fixed on a git developer install (horde/prefs
symlinked via path repository). I don't have a standard composer
(non-symlinked) install to test against. The fixed-depth path this
patch falls back to is unchanged from the existing code, and by
inspection it matches the directory structure composer produces for
a standard install (vendor/horde/prefs/bin, 4 levels from project
root) — but I haven't actually run this against one. Would
appreciate a confirmation from someone with a standard install.
Searched the entire /var/www/horde-git tree for other bin scripts sharing this
same bootstrap pattern (grep -rl 'handle "git developer install"'). One other
file matched — horde/components/bin/horde-components — but it uses a different
path structure (different depths, plus an additional config/autoload.php entry)
and serves a different purpose (build tool for the .phar, with a separate
GitHub webhook mode). Out of scope for this fix.