Permalink
Browse files

FIX: Move stage choosing into a pre-request filter.

This ensures that the correct stage is selected, even if the request
does not come through the model as controller system. This fixes an
issue where custom controllers would always be on the "Stage" stage.
  • Loading branch information...
ajshort authored and ss23 committed Oct 3, 2013
1 parent 699272a commit e7c8fed6ab99c99dd04086681b8305df4c795e37
Showing with 25 additions and 0 deletions.
  1. +8 −0 _config/requestprocessors.yml
  2. +17 −0 control/VersionedRequestFilter.php
@@ -0,0 +1,8 @@
+---
+Name: requestprocessors
+---
+Injector:
+ RequestProcessor:
+ properties:
+ filters:
+ - '%$VersionedRequestFilter'
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Initialises the versioned stage when a request is made.
+ *
+ * @package framework
+ * @subpackage control
+ */
+class VersionedRequestFilter {
+
+ public function preRequest() {
+ Versioned::choose_site_stage();
+ }
+
+ public function postRequest() {
+ }
+
+}

5 comments on commit e7c8fed

Owner

halkyon replied Nov 20, 2013

@ajshort This caused a regression in the 3.0 branch. If you create a page in the CMS, the record goes into SiteTree_Live, but not SiteTree, and thus the newly created page shows as "Deleted from stage" in the CMS. It's a bit of a severe issue :)

Any ideas on what's going on?

Contributor

ajshort replied Nov 20, 2013

Nope, I never actually tested this patch, just emailed it off a while ago and it got merged in.

Contributor

ss23 replied Nov 20, 2013

The related CMS fix was never merged into 3.0. Should be fixed soon.

Owner

halkyon replied Nov 20, 2013

This was fixed by cherry-picking 3d9fc2c from 3.1 into 3.0.

Contributor

madmatt replied Nov 20, 2013

If it doesn't click immediately for you, as it didn't for me, the commit hash that halkyon posted is for silverstripe-cms, not silverstripe-framework, so the link doesn't work.

Here's the proper link to the cherry-picked commit: silverstripe/silverstripe-cms@3d9fc2c

Please sign in to comment.