mitydigital / statamic-sitemapamic

A simple XML sitemap generator for Statamic 3, 4 and 5
13 stars 5 forks source link

Date comparison datatype issue results in error #23

Open RyanDrewniak opened 1 month ago

RyanDrewniak commented 1 month ago

Bug description

When I use this plugin on my staging environment, I get the following fatal error:

Object of class Illuminate\\Support\\Carbon could not be converted to int

which is triggered at:

vendor/mitydigital/sitemapamic/src/Support/Sitemapamic.php:303

Steps to reproduce

Install the plugin on a site running Statamic v5.20.0 and load the sitemap.xml URL from any web browser.

Environment and versions

Environment
Laravel Version: 10.48.12
PHP Version: 8.2.20
Composer Version: 2.2.6
Environment: development
Debug Mode: ENABLED
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: redis
Database: mysql
Logs: stack / single, slack
Mail: mailgun
Queue: sync
Session: redis

Livewire
Livewire: v3.4.9

Sentry
Enabled: YES
Environment: development
Laravel SDK Version: 4.6.1
PHP SDK Version: 4.8.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED

Statamic
Addons: 5
Sites: 5
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.20.0 PRO

Statamic Addons
alt-design/alt-redirect: 1.3.2
jacksleight/statamic-bard-mutator: 2.3.1
jacksleight/statamic-bard-texstyle: 3.2.3
mitydigital/sitemapamic: 3.1.0
statamic/eloquent-driver: 4.12.3

Statamic Eloquent Driver
Asset Containers: file
Assets: file
Blueprints: file
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: file
Taxonomies: eloquent
Terms: eloquent
Tokens: file

Additional details

To test the issue, I inserted a dd($entryLastMod, $lastMod); at line 301 of the vendor/mitydigital/sitemapamic/src/Support/Sitemapamic.php file. When I do so, the $entryLastMod variable is presented as an int but the $lastMod is set as a Carbon object.

RyanDrewniak commented 1 month ago

I did some additional debugging and just submitted a forked pull request that should fix the problem: https://github.com/mitydigital/statamic-sitemapamic/pull/24

martyf commented 1 month ago

Before merging the PR I'd like to be able to replicate it as I've not seen this happen in any environment before.

I've done a clean install but runs for me.

What is special about your environment that is causing this issue to occur?

Can you reproduce it in a repo? I've set up a new site, with L10, Eloquent driver, but can't replicate this issue. While the PR does fix it, I'd also like to understand what is causing the issue too.

RyanDrewniak commented 1 month ago

That's so unbelievably bizarre...I tried in a different environment (3 different environments now) with the exact same dataset, but I can't replicate the issue. I'm thinking it may be related to some separate server configuration setting on that one environment.

martyf commented 1 month ago

Just to be clear too, I’m not discounting the issue either: just want to understand why it’s happening.

Can you dig a little deeper with a fresh install on the same environment to find the right steps to replicate?