Page_params: Relocation doesn't work for first page

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Page_params: Relocation doesn't work for first page

Post by cmb » Fri Dec 26, 2014 11:14 pm

Hello Community,

in a German thread Duffy6 and Ludwig reported that the relocation (page_params: "Redirect page?") doesn't work for the start page when the installation is requested directly (i.e. without the "page URL"). Indeed, that is a bug because the relocation checks for $s (which is not properly set then in this case) instead of $pd_s.

Note that even though $pd_s is only predicted[1] it's okay to trigger the relocation preparation, because that does not do the relocation directly, but instead temporarily overwrites the respective page content. If it later (after the plugin loading) turns out that the start page hasn't been requested, the actual relocation will not be triggered.

I suggest the following patch:

Code: Select all

Index: plugins/page_params/index.php
===================================================================
--- plugins/page_params/index.php	(revision 3)
+++ plugins/page_params/index.php	(working copy)
@@ -38,7 +38,7 @@
  *
  * @return void
  *
- * @global int    The index of the current page.
+ * @global int    The predicted index of the current page.
  * @global string The script name.
  * @global array  The content of the pages.
  *
@@ -46,7 +46,7 @@
  */
 function Pageparams_handleRelocation($index, $data)
 {
-    global $s, $sn, $c;
+    global $pd_s, $sn, $c;
 
     $location = $data['header_location'];
     if ((int) $data['use_header_location'] > 0 && trim($location) !== '' ) {
@@ -54,7 +54,7 @@
         if (!$components || !isset($components['scheme'])) {
             $location = CMSIMPLE_URL . $location;
         }
-        if ($index == $s) {
+        if ($index == $pd_s) {
             $c[$index] = '#CMSimple header("Location:'. $location .'"); exit; #';
         }
     }
Christoph

PS: [1] "preliminary" might be the better term.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Page_params: Relocation doesn't work for first page

Post by cmb » Sun Dec 28, 2014 5:19 pm

Done (r1421).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply