Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon update called many times #11082

Open
edalzell opened this issue Nov 7, 2024 · 8 comments · May be fixed by #11128
Open

Addon update called many times #11082

edalzell opened this issue Nov 7, 2024 · 8 comments · May be fixed by #11128
Labels

Comments

@edalzell
Copy link
Contributor

edalzell commented Nov 7, 2024

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@duncanmcclean
Copy link
Member

Do all of those service providers extend Statamic's AddonServiceProvider?

@edalzell
Copy link
Contributor Author

Do all of those service providers extend Statamic's AddonServiceProvider?

Yes they do, because they have tags etc and I want them loaded.

@duncanmcclean
Copy link
Member

Okay! We can probably provide a way to opt-out of auto registration then.

@edalzell
Copy link
Contributor Author

Okay! We can probably provide a way to opt-out of auto registration then.

How will that help? I only have ONE update script at the correct relative location, why is that one getting called for the other service providers?

@duncanmcclean
Copy link
Member

For the record: we've chatted this out on Slack. Instead of autoloading based on the addon's path, we can use the service provider's path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants