statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.58k stars 489 forks source link

[5.x] Calling commands from addons #9861

Closed robdekort closed 2 months ago

robdekort commented 2 months ago

Bug description

I have an addon that adds certain commands to Peak sites. In some of those commands I call other Artisan commands:

  1. Artisan::call('cache:clear');
  2. Artisan::call('statamic:glide:clear')

In one command I call them both.

In v5 Alpha 1 and 2 triggering those commands leads to an error:

Screenshot 2024-04-11 at 09 32 27

When I replicate those commands in my actual project (and not in an addon) they work without issue. I can replace the cache:clear command with \Illuminate\Support\Facades\Cache::clear() and that works, however there's no alternative like that for the statamic:glide:clear command.

How to reproduce

  1. Install the v5 alpha.
  2. Create an addon.
  3. Add a simple command to the addon.
  4. Call an artisan command from the addon.

Logs

No response

Environment

Environment
Application Name: Statamic Peak Development
Laravel Version: 11.3.1
PHP Version: 8.3.4
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: statamic-peak.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.0.0-alpha.2 PRO

Statamic Addons
studio1902/statamic-peak-browser-appearance: dev-feature/v5-support
studio1902/statamic-peak-commands: dev-feature/v5-support
studio1902/statamic-peak-seo: dev-feature/v5-support
studio1902/statamic-peak-tools: dev-feature/v5-support

Installation

Starter Kit using via CLI

Antlers Parser

None

Additional details

No response

duncanmcclean commented 2 months ago

I'm assuming you were doing it inside php please command, correct?

Can you try running that same command but with Artisan, so php artisan statamic:*?

robdekort commented 2 months ago

Correct, and that makes it work Duncan!

duncanmcclean commented 2 months ago

Cool, thanks for testing! We probably need to do some more tweaking on our side regarding how please works (related: #9729).

robdekort commented 2 months ago

Cool, glad you're on the right path!

robdekort commented 2 months ago

Screenshot 2024-04-18 at 09 51 44

On Alpha 4, I still notice an issue with the glide command. Notice in the screenshot above that:

The artisan cache:clear command (that is also part of clear-site) however ran without issue.

duncanmcclean commented 2 months ago

Not saying it's the fix but can you try Artisan::call('peak:clear-site') (so without the statamic: prefix)?

robdekort commented 2 months ago

Do you mean Artisan::call('glide:clear')?

duncanmcclean commented 2 months ago

Sorry, yeah.

robdekort commented 2 months ago

Yep, that works!

robdekort commented 2 months ago

Should I just use that and consider the case closed?

duncanmcclean commented 2 months ago

Nah, leave it open, it should work with the statamic: prefix.

jasonvarga commented 2 months ago

Nah I'd expect Artisan::call('statamic:glide:clear') to be what you need to run and not Artisan::call('glide:clear'). We'll sort it out. Thanks!

robdekort commented 2 months ago

Hokey dokey. Thanks guys.

jasonvarga commented 2 months ago

Fixed in #9926