Comments (4)
Hey, I can't see any weird behavior with a new Laravel + Jetstream installation. Can you share a simple repo demonstrating this issue?
from clockwork.
Sorry for late response. Here is demo repo https://github.com/zaminhub/jetstream.test.git
cloclwork installed store method doesn't work.
from clockwork.
Hello @itsgoingd Did you check the demo repo above?
from clockwork.
Hey, sorry, forgot about this one, thanks for reminding me. Turns out this is quite a convoluted issue. I will try to explain.
The code that triggers this behavior is this line in your javascript code:
https://github.com/zaminhub/jetstream.test/blob/master/resources/js/Pages/Posts/PostModal.vue#L19
This ends up sending a POST request with an empty _method
override when trying to create new posts. When editing existing posts, the override is set to PUT, making it work.
On server-side, Clockwork checks the method of the incoming request, very early in the processing. To do so, we call $request->getMethod()
, which is a method from the underlying Symfony HTTP request implementation. This method does a bunch of things, resolves the base request method, tries to apply various types of overrides and validates the result.
Since your app is sending request with an empty _method
override, the method executes all the way up to the following validation step, which fails (since $method
is an empty string) and an exception is thrown. I assume since this is very early in the request processing, the exception ends up being interpreted as 404 error (haven't looked into this part that much).
https://github.com/symfony/http-foundation/blob/7.1/Request.php#L1166-L1168
Well, a good question is, why does this work without Clockwork?
Turns out, Laravel includes a middleware, that replaces empty strings in the request by nulls. Now when we call the same getMethod()
method, we will hit this early return and never reach the exception part.
https://github.com/symfony/http-foundation/blob/7.1/Request.php#L1156-L1158
The issue with Clockwork installed is the execution order, which looks like this:
Request is received
Clockwork calls getMethod() // _method is empty string and exception is thrown
ConvertEmptyStringsToNull middleware is ran
Routing calls getMethod() // _method is null now, so the call defaults to POST
TL;DR I'm not sure if or how we want to fix this in Clockwork, but you can trivially fix this on your side, by adding POST as default value to _method
, or not including that key at all.
from clockwork.
Related Issues (20)
- (Laravel) Chrome extension has option to "Load more", but the web page doesn't? HOT 1
- Show listeners in events data source HOT 1
- Changed default behavior HOT 3
- Slack Message Notification tries to access protected property HOT 5
- Serialization Failure in Clockwork Due to Incomplete Object Representations HOT 5
- Bug: Exception when Notification class missing toArray() method HOT 2
- Symfony 7 Compatibility issues HOT 3
- Where is the response in this? HOT 4
- addDatabaseQuery does not increase queries count HOT 2
- Laravel 11 support HOT 2
- Profile is not present for current request HOT 1
- No such file in iframe.html.php HOT 3
- Installed Clockwork and it broke my app? HOT 3
- PhpUnit 10: Cannot override final method PHPUnit\Framework\Assert::assertThat() HOT 1
- Chrome Extension needs to be updated to Manifest v3 HOT 5
- Will be released a 5.3 version to include the new PSR middleware? HOT 2
- Using Redis storage without user/password HOT 3
- request improving filter feature HOT 4
- Cant find how to open historical json HOT 1
- Laravel Clockwork not working with chromium based browser
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clockwork.