Problem/Motivation
We need a way to put a Drupal site in and out of maintenance mode in a fully decoupled admin UI.
Proposed resolution
Option 1:
Add a single "maintenance_mode.enabled" method with a "enabled" boolean parameter to the JSON RPC methods.
Option 2:
Add 2 seperate methods without parameters:
- "maintenance_mode.enable"
- "maintenance_mode.disable"
Remaining tasks
- Decide which option is the most desirable
- Add maintenance_mode method(s) to jsonrpc_core module methods
- Write tests
- Document request and response structure
- Review
- Commmit
User interface changes
None.
API changes
- The discovery will report an aditional method, "maintenance_mode"
- The /jsonrpc endpoint will accept requests for the "maintenance_mode" method
Data model changes
None.
Comments
Comment #2
rogierbom commentedComment #3
gabesulliceHi @rogierbom! Great idea and great issue!
I think my preference would be for option #1, but changing "state" to "enabled" so it's a little clearer whether it's on or off. We should be sure that a client can send TRUE, even if it is already TRUE in order to keep the method idempotent.
One larger question: perhaps we should generalize this even more and just make a State API service rather than specific methods for each state variable. What do you think?
Comment #4
e0ipso+1 to this issue.
I'm very tempted by this suggestion. The only inconvenience will be that we won't be able to have a consistent schema for the RPC method, which is unfortunate. This is because the values in the keyval store have different (and unanticipated) shapes. I don't think this is a blocker, but maybe we can make it work.
Comment #5
rogierbom commentedComment #6
rogierbom commentedHere is an initial patch that implements option 1, with the remarks of @gabesullice. The test breaks on a validation issue in the JsonRpcMethodManager, I wil file a separate issue for this.
I don't know how I feel about just exposing the State API and using that endpoint to perform actions like this one. From the perspective of a decoupled admin UI it makes sense. But on the other hand it would require other (non-Drupal) consumers to have knowledge of the internal structure of the State API to perform these actions. I myself would prefer a dedicated and clear method for this.
Comment #7
e0ipsoThanks for the patch @rogierbom! This looks really good. Some minor details:
Maybe
"maintenance_mode.isEnabled"Let's either return 204 or the actual status of the state:
How is this dependency used?
Do we need to login if we are going to use basic auth?
DCS Nit: extra line break.
The user to be used for Basic Auth authentication.
DCS Nit: missing line break.
I wonder if we should at have a base class that contains the code that would be reused in other State API related RPC mehtods.
Comment #8
dinesh18 commentedFixed as per the comment #7.
Attached updated patch and interdiff
Comment #10
e0ipsoMerged, tagged and released. Thanks for you awesome contribution!