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

Ensure the config is valid before subscribing to events #16

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

mcaskill
Copy link
Contributor

@mcaskill mcaskill commented Mar 2, 2023

Prevents an error in EnvatoPlugin:

Call to a member function getDownloadUrl() on null

This error is the result of the EnvatoApi not being set up when the config is invalid but events still being subscribed to.

Prevents an error in EnvatoPlugin:

> Call to a member function `getDownloadUrl()` on null
@szepeviktor
Copy link
Owner

Thank you.
The fix is correct.

@szepeviktor szepeviktor merged commit 158807b into szepeviktor:master Mar 2, 2023
@mcaskill mcaskill deleted the fix-subscribed-events branch March 2, 2023 16:19
@mcaskill
Copy link
Contributor Author

mcaskill commented Mar 2, 2023

🤦 The fix is not correct; the getSubscribedEvents() method is static. Sorry about that. I'll push a better correction soon.

@mcaskill
Copy link
Contributor Author

mcaskill commented Mar 2, 2023

I can either move the config validity check to handlePreDownloadEvent():

public function handlePreDownloadEvent(PreFileDownloadEvent $event): void
{
    if ($event->getType() !== 'package' || ! $this->config->isValid()) {
        return;
    }

Or change the $config property to be static.

@szepeviktor
Copy link
Owner

Oh noooooooooooooooooooooooooooooooooooooooooooooooooooooooo!

I leave it 100% up to you.
This PR is not yet released :)

@szepeviktor
Copy link
Owner

Please run composer run analyze before that PR.

mcaskill added a commit to mcaskill/composer-envato that referenced this pull request Mar 2, 2023
Amends 158807b (szepeviktor#16)

The `EnvatoPlugin::getSubscribedEvents()` method is static preventing us from checking the instance property `$config`. Moved config validation check to `handlePreDownloadEvent()`.
szepeviktor pushed a commit that referenced this pull request Mar 2, 2023
Amends 158807b (#16)

The `EnvatoPlugin::getSubscribedEvents()` method is static preventing us from checking the instance property `$config`. Moved config validation check to `handlePreDownloadEvent()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants