Add revised clear-compiled artisan command#5727
Merged
ryancooley merged 3 commits intodevelopfrom Nov 30, 2023
Merged
Conversation
nolanpro
approved these changes
Nov 30, 2023
|
SonarQube Quality Gate |
boliviacoca
approved these changes
Nov 30, 2023
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.








Issue
The command
php artisan clear-compiledartisan command is run (on the command line or programmatically) it flushes the package manifest.This is an issue since the licensed packages are loaded based on the package manifest and if that file is cleared, it will attempt to load all installed packages, including custom ones, which triggers a fatal error.
Reproduction Steps
php artisan license:update {licenseFile}command and ensure it runs successfullyphp artisan upgrade{"errors":{"username":["cURL error 3: URL rejected: No host part in the URL (see https:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html) for \/api\/1.0\/\/integratingpm3onpm4\/user?username=admin"]}}This happens because one of the custom packages has a
UserObserverlistening for user activities and is triggered by one of the upgrade migrations updating user information. TheUserObserverlooks for specific environment variables to be set and if they’re not found, it callsdie()which immediately kills the process.The greater problem is that the custom package’s service provider was being loaded in the first place. There are two programmatic calls to the
clear-compiledartisan command, one in an upgrade migration and one in package-cdata.Solution
Create a customized version of the php artisan clear-compiled command programmatically and runphp artisan package:discoverto ensure it is rebuilt before continuing.Listen for clear-compiled and optimize:clear commands and return package:discover
How to Test
php artisan clear-compiledcommand and check through thebootstrap/cache/packages.phpfile to ensure it contains only licensed packages.Related Tickets & Packages
Code Review Checklist