File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -358,13 +358,22 @@ public function flushrendercache(): void
358
358
359
359
/**
360
360
* Update a page in the database
361
+ * Check if page version match the one stored in database
361
362
*
362
363
* @param Page $page The page that is going to be updated
363
364
*
364
365
* @throws Databaseexception in case of error
366
+ * @throws RangeException If original page version is invalid
365
367
*/
366
368
public function update (Page $ page ): void
367
369
{
370
+ $ oldpage = $ this ->get ($ page );
371
+ if ($ page ->version () !== $ oldpage ->version ()) {
372
+ $ vnew = $ page ->version ();
373
+ $ vold = $ oldpage ->version ();
374
+ throw new Databaseexception ("page version ( $ vnew) does not match original page in database ( $ vold) " );
375
+ }
376
+
368
377
$ pagedata = new Document ($ page ->dry ());
369
378
$ pagedata ->setId ($ page ->id ());
370
379
$ this ->updatedoc ($ pagedata );
You can’t perform that action at this time.
0 commit comments