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

404 viewing spam submission in control panel #52

Open
mrcalc opened this issue Jul 26, 2024 · 4 comments
Open

404 viewing spam submission in control panel #52

mrcalc opened this issue Jul 26, 2024 · 4 comments

Comments

@mrcalc
Copy link

mrcalc commented Jul 26, 2024

Current Behavior

Viewing spam submissions in the queue gives a 404 error (Page not found)
http://localhost/cp/akismet/queues/contact_us/spam/1721962338.9203

Expected Behavior

Viewing spam submissions in the queue shows the submission.

Possible Solution

This issue seems to be an incompatibility between route binding for {id} and Statamic's use of microtime for IDs.

Spam submissions are stored with the filename created from microtime(true) which contains a dot e.g. 1721962338.9203.yaml.

When this is used in a route with '{id}' it doesn't match id in the route Route::get('{id}', [ShowSpamController::class, '__invoke'])->name('show'); and falls through to the CpController pageNotFound method.

If it is working for other sites, this may be an incompatibility with the environment (see below).

Statamic form submission routes bind on $submission - see Statamic\Http\Controllers\CP\Forms\FormSubmissionsController::show

It seems to work if the route binding uses {submission} instead of {id}. This needs more testing.

// src/routes/cp.php
// Line 28
Route::get('{submission}', [ShowSpamController::class, '__invoke'])->name('show');

Steps to Reproduce

  1. Setup statamic-akismet from readme.md
  2. Submit a form with email address [email protected]
  3. Check storage/app/spam/contact_us for new spam submission with the filename based on the microtime of the submission e.g. 1721962338.9203.yaml.
  4. Navigate to http://localhost/cp/akismet/queues/contact_us/spam/1721962338.9203 and see Page not found error. ShowSpamController __invoke is not hit.
  5. Navigate to http://localhost/cp/akismet/queues/contact_us/spam/1721962338 and ShowSpamController __invoke is hit but because there isn't a submission it shows an empty spam submission.

Context (Environment)

Environment
Application Name: Test
Laravel Version: 10.48.15
PHP Version: 8.2.14
Composer Version: 2.6.6
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF

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

Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / daily
Mail: smtp
Queue: database
Session: file

Statamic
Addons: 4
Sites: 2 (Test1, Test2)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.17.0 PRO

Statamic Addons
edalzell/forma: 3.0.1
silentz/akismet: 5.0
stoffelio/statamic-turnstile: 1.2.1
studio1902/statamic-peak-seo: 8.15.3

@edalzell
Copy link
Contributor

Thanks for this, I'll look this week.

@edalzell
Copy link
Contributor

edalzell commented Aug 23, 2024

Sorry for the delay but I can't reproduce this.
CleanShot 2024-08-22 at 18 14 53@2x

What versions of things are you using? Can you please post the output of php please support:details?

@mrcalc
Copy link
Author

mrcalc commented Aug 23, 2024

Thanks. See Context (Environment) above for support details. I will check that it's not caused by other code on the site.

@edalzell
Copy link
Contributor

See Context (Environment) above for support details

Sigh, I could learn to read.

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

No branches or pull requests

2 participants