Problem/Motivation
When using composer's optimize-autoloader setting, this module throws warnings and is skipped.
❯ ddev composer require drupal/cloudfront_cache_path_invalidate
./composer.json has been updated
Running composer update drupal/cloudfront_cache_path_invalidate
Loading composer repositories with package information
Updating dependencies
Lock file operations: 4 installs, 0 updates, 0 removals
- Locking aws/aws-crt-php (v1.2.7)
- Locking aws/aws-sdk-php (3.325.3)
- Locking drupal/cloudfront_cache_path_invalidate (3.0.9)
- Locking mtdowling/jmespath.php (2.8.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
- Installing aws/aws-crt-php (v1.2.7): Extracting archive
- Installing mtdowling/jmespath.php (2.8.0): Extracting archive
- Installing aws/aws-sdk-php (3.325.3): Extracting archive
- Installing drupal/cloudfront_cache_path_invalidate (3.0.9): Extracting archive
3 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
Class Drupal\cloudfront_cache_path_invalidate\Form\AutoCloudfrontCacheSettingForm located in ./web/modules/contrib/cloudfront_cache_path_invalidate/src/Form/AutoCloudfrontCacheSettingForm.php does not comply with psr-4 autoloading standard (rule: Drupal\CloudfrontCachePathInvalidate\ => ./web/modules/contrib/cloudfront_cache_path_invalidate/src). Skipping.
Class Drupal\cloudfront_cache_path_invalidate\Form\CloudfrontCacheInvalidateForm located in ./web/modules/contrib/cloudfront_cache_path_invalidate/src/Form/CloudfrontCacheInvalidateForm.php does not comply with psr-4 autoloading standard (rule: Drupal\CloudfrontCachePathInvalidate\ => ./web/modules/contrib/cloudfront_cache_path_invalidate/src). Skipping.
44 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Found 4 security vulnerability advisories affecting 3 packages.
Run "composer audit" for a full list of advisories.
Using version ^3.0 for drupal/cloudfront_cache_path_invalidate
Specifically this part:
Generating optimized autoload files
Class Drupal\cloudfront_cache_path_invalidate\Form\AutoCloudfrontCacheSettingForm located in ./web/modules/contrib/cloudfront_cache_path_invalidate/src/Form/AutoCloudfrontCacheSettingForm.php does not comply with psr-4 autoloading standard (rule: Drupal\CloudfrontCachePathInvalidate\ => ./web/modules/contrib/cloudfront_cache_path_invalidate/src). Skipping.
Class Drupal\cloudfront_cache_path_invalidate\Form\CloudfrontCacheInvalidateForm located in ./web/modules/contrib/cloudfront_cache_path_invalidate/src/Form/CloudfrontCacheInvalidateForm.php does not comply with psr-4 autoloading standard (rule: Drupal\CloudfrontCachePathInvalidate\ => ./web/modules/contrib/cloudfront_cache_path_invalidate/src). Skipping.
Steps to reproduce
- Set up a new Drupal site (I used Drupal 10 but 11 should reproduce the same way)
- Enable composer optimizer-autoloader, in composer.json under
config add "optimize-autoloader": true
- Run
composer require drupal/cloudfront_cache_path_invalidate
The expected result is no warnings and an optimized autoloader, but the actual result is the warning shown above.
Proposed resolution
Remove the unneeded and incorrect autoload section from composer.json.
Remaining tasks
Create MR
Test
- Review
- Commit
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Comments
Comment #2
star-szrComment #4
star-szrTested by modifying composer.json repositories:
And ran
ddev composer require drupal/cloudfront_cache_path_invalidate:dev-3485969-incorrect-composer.json-psr-4Result (no warnings!):
Comment #5
star-szrComment #6
mparker17I've tested this patch on two different sites, and it works for me!
Comment #8
mparker17Awesome, thanks @prashant mishra!
Comment #9
prashant mishra commentedComment #10
star-szr@prashant mishra Can you please update the issue credits to give us credit as well? Thanks in advance.
Comment #11
prashant mishra commentedCredit has been given.