From c31ce61da6d986c705c63490cf34477486c87a23 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Sun, 25 Jun 2017 00:47:37 +0200 Subject: [PATCH] properly handle SiteTree objects when changing a page, we have to use writeToStage and publish ... when using just 'write' the page will get a modified label in the cms, but the changes will not be visible ... what might be interesting, is to provide an argument for PUT/POST to decide if the record should be published or just staged. --- code/queryHandlers/RESTfulAPI_DefaultQueryHandler.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/queryHandlers/RESTfulAPI_DefaultQueryHandler.php b/code/queryHandlers/RESTfulAPI_DefaultQueryHandler.php index bc63632..5b07a2b 100644 --- a/code/queryHandlers/RESTfulAPI_DefaultQueryHandler.php +++ b/code/queryHandlers/RESTfulAPI_DefaultQueryHandler.php @@ -427,7 +427,13 @@ public function updateModel($model, $id, $request) if ($hasChanges || !$model->ID) { try { - $id = $model->write(false, false, false, $hasRelationChanges); + if (is_a($model,'SiteTree')){ + $id = $model->writeToStage('Stage'); + $model->publish('Stage', 'Live'); + } + else { + $id = $model->write(false, false, false, $hasRelationChanges); + } } catch (ValidationException $exception) { $error = $exception->getResult(); return new RESTfulAPI_Error(400,