aerni / statamic-advanced-seo

Comprehensive SEO addon for Statamic with flexibility in mind
https://statamic.com/addons/aerni/advanced-seo
11 stars 6 forks source link

Issue with SeoVariablesPolicy::view() Causing Server Error in Statamic Application #118

Closed thepalk closed 8 months ago

thepalk commented 8 months ago

Description

After a recent update, our Statamic application started encountering a 500 Server Error for non-super users. The error is specifically related to the Aerni\AdvancedSeo\Policies\SeoVariablesPolicy::view() method. The method is expecting an argument of type Aerni\AdvancedSeo\Data\SeoDefaultSet, but null is provided instead.

Error Message

Aerni\AdvancedSeo\Policies\SeoVariablesPolicy::view(): Argument #2 ($set) must be of type Aerni\AdvancedSeo\Data\SeoDefaultSet, null given, called in /path/to/vendor/aerni/advanced-seo/src/Policies/SeoVariablesPolicy.php on line 15

Environment

Troubleshooting Steps Taken

  1. Checked for compatibility issues.
  2. Reviewed Advanced SEO configuration files.
  3. Cleared application caches.
  4. Tested in both production and local development environments, encountering the same issue.

Temporary Solution

Uninstalling the aerni/advanced-seo addon resolved the issue, indicating a potential problem with the addon in the given environment.

Expected Behavior

The SeoVariablesPolicy::view() method should handle the provided arguments correctly without causing a server error.

Actual Behavior

The method is throwing an error due to a null value being passed where an instance of Aerni\AdvancedSeo\Data\SeoDefaultSet is expected.

aerni commented 8 months ago

This issue doesn't happen for me. Please provide a repo that reproduces the issue. Happy to take a look at it.

thepalk commented 8 months ago

https://github.com/thepalk/trytorepseoprob

Hello Aerni,

Apologies for the delay in responding. To replicate the error you mentioned, please follow these steps:

Log in using the credentials: Email: test@test.test Password: testtest After logging in, please impersonate the user 'testy'. Alternatively,

You can directly log in as 'testy' using: Email: testy@tets.test Password: testtest Once you have completed these steps, you should be able to observe the error in question.

Thank you for your patience and cooperation.

Best regards, Pavlo

aerni commented 8 months ago

Thanks. This was an easy fix.

thepalk commented 8 months ago

Awesome, thank you.