statamic / cms

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

Addon update called many times #11082

Open edalzell opened 1 week ago

edalzell commented 1 week ago

Bug description

Our addon's updater gets called many times: CleanShot 2024-11-06 at 15 56 37@2x

How to reproduce

Run composer dump-autoload when your add-on's updater looks like:

<?php

namespace TransformStudios\Simple\UpdateScripts;

use Illuminate\Support\Facades\App;
use Statamic\UpdateScripts\UpdateScript;
use TransformStudios\Simple\SimpleFacade as Simple;

class Updater extends UpdateScript
{
    public function shouldUpdate($newVersion, $oldVersion)
    {
        return App::isLocal();
    }

    public function update()
    {
        Simple::updateConfigs();
        Simple::publishFiles();
        Simple::setDigitalGuidelineSites();
    }
}

It's using the auto-loading that was recently added.

Logs

No response

Environment

Environment
Application Name: Sacramento Airport
Laravel Version: 11.30.0
PHP Version: 8.3.13
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: sacair.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

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

Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.5.12

Statamic
Addons: 13
Sites: 6 (Sacramento Airport, Sacramento County Department of Airports, Sacramento International Airport, and 3 more)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.37.0 PRO

Statamic Addons
aryehraber/statamic-captcha: 1.13.0
edalzell/forma: 3.0.1
jacksleight/statamic-bard-mutator: 2.3.1
jacksleight/statamic-distill: 0.8.0
jonassiewertsen/statamic-livewire: 3.8.1
statamic-rad-pack/runway: 7.12.0
statamic/seo-pro: 6.3.0
transformstudios/events: 5.4.3
transformstudios/front: 3.0.1
transformstudios/github: dev-main
transformstudios/review: 5.0
transformstudios/simple: dev-fix/user-migrations
transformstudios/skidata: dev-main

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 2 days ago

I'm unable to reproduce this with a fresh site & addon. 🤔

CleanShot 2024-11-11 at 15 11 51

What does your addon's ServiceProvider look like?

edalzell commented 1 hour ago

Oh I bet it has something to with the fact I load a bunch of service providers in the composer.json:

CleanShot 2024-11-13 at 15 40 15@2x

edalzell commented 1 hour ago

Yup, 9 service providers and it's called 9 times