fix(composer): add fallback autoload for Composer dependency installs#1074
Open
faisalahammad wants to merge 4 commits into
Open
fix(composer): add fallback autoload for Composer dependency installs#1074faisalahammad wants to merge 4 commits into
faisalahammad wants to merge 4 commits into
Conversation
When Imagify is installed via Composer as a dependency (e.g. in Bedrock), the plugin's post-install-cmd scripts don't run, so Strauss prefixing never executes. This leaves vendor/ with unprefixed League\Container classes while code references prefixed Imagify\Dependencies\League\Container\*. Fix: Add class_alias fallbacks in inc/main.php to map unprefixed classes to prefixed namespace when needed. Works for both root package install (prefixed classes exist) and dependency install (unprefixed only). Fixes wp-media#1073
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Move FILTER_REQUIRE_ARRAY to flags arg in filter_input call. Add use statement for Container in inc/main.php to fix class not found error during integration test bootstrap.
- Skip ImagifyUser integration tests when IMAGIFY_TESTS_API_KEY is empty (e.g. fork PRs without repo secrets) instead of failing with WP_Error - Pass null as object to ReflectionProperty::setValue() for static properties to avoid PHP 8.4 single-arg deprecation
Add `if: github.event.pull_request.head.repo.fork == false` guard to the codacy-coverage-reporter step. Fork PRs don't have access to CODACY_PROJECT_TOKEN secret, causing the step to fail with "Invalid configuration: Either a project or account API token must be provided." On same-repo PRs behavior is unchanged.
|
Same issue here. Please merge it if works. |
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
Fix fatal error when plugin is installed via Composer (e.g. Bedrock). Strauss prefixing does not run when installed as a dependency, so
Imagify\Dependencies\League\Container\*classes are missing.Add
class_aliasfallback ininc/main.phpto map unprefixed League classes to the prefixed namespace. Also fixFILTER_REQUIRE_ARRAYPHPStan error inclasses/Bulk/Bulk.php.Type of change
Detailed scenario
What was tested
How to test
composer require wp-media/imagify-pluginAffected Features & Quality Assurance Scope
Technical description
Documentation
N/A — code change only, no public API change.
New dependencies
None.
Risks
Low. The
class_aliasfallback only activates when the prefixed class is not already available. Thefilter_inputchange movesFILTER_REQUIRE_ARRAYto the$flagsargument (4th) where it belongs.Mandatory Checklist
Code validation
composer run-stanpassescomposer phpcspassesCode style
Unticked items justification
N/A
Additional Checks