Fix an issue where wiki page aliases were not working, a=chris
Fix an issue where wiki page aliases were not working, a=chris
diff --git a/src/controllers/Controller.php b/src/controllers/Controller.php
index 0a86c7a8c..78760bfa0 100755
--- a/src/controllers/Controller.php
+++ b/src/controllers/Controller.php
@@ -335,7 +335,13 @@ abstract class Controller
}
}
}
+ //route info trumps query params except when a wiki page
if (isset($_REQUEST['route'])) {
+ if (!empty($query_array['page_name']) &&
+ !empty($query_array['c']) ) {
+ $_REQUEST['route']['c'] = $query_array['c'];
+ $_REQUEST['route']['page_name'] = $query_array['page_name'];
+ }
foreach ($query_array as $field => $value) {
if (!empty($_REQUEST['route'][$field])) {
unset($query_array[$field]);
@@ -374,6 +380,18 @@ abstract class Controller
$_FILES = []; // this is for when Yioop run as own web server
L\webExit();
}
+ /**
+ * Method to perform a 302 redirect to $location in both under web server
+ * and CLI setting
+ *
+ * @param string $location url to redirect to
+ */
+ public function redirectLocation($location)
+ {
+ $this->web_site->header("Location:$location");
+ $_FILES = []; // this is for when Yioop run as own web server
+ L\webExit();
+ }
/**
* When an activity involves displaying tabular data (such as rows of
* users, groups, etc), this method might be called to set up $data
diff --git a/src/controllers/StaticController.php b/src/controllers/StaticController.php
index cfc4b6f21..c6e4f60ba 100644
--- a/src/controllers/StaticController.php
+++ b/src/controllers/StaticController.php
@@ -30,6 +30,7 @@
*/
namespace seekquarry\yioop\controllers;
+use seekquarry\yioop as B;
use seekquarry\yioop\configs as C;
use seekquarry\yioop\library as L;
@@ -180,8 +181,7 @@ EOD;
if (isset($head_info['page_type']) &&
$head_info['page_type'] == 'page_alias' &&
$head_info['page_alias'] != '' ) {
- $_REQUEST['p'] = $head_info['page_alias'];
- return $this->redirectWithMessage("", ['p']);
+ return $this->redirectLocation(B\wikiUrl($head_info['page_alias']));
}
if ((isset($head_info['title']))) {
if ($head_info['title']) {
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index 094e6fe11..836fda53c 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -2704,8 +2704,10 @@ class SocialComponent extends Component implements CrawlConstants
$data["HEAD"]['page_type'] == 'page_alias' &&
$data["HEAD"]['page_alias'] != '' &&
$data['MODE'] == "read" && !isset($_REQUEST['noredirect']) ) {
- $_REQUEST['page_name'] = $data["HEAD"]['page_alias'];
- return $parent->redirectWithMessage("", ['page_name']);
+ return $parent->redirectLocation(B\wikiUrl(
+ $data["HEAD"]['page_alias'],
+ true, $controller_name, $group_id) . C\CSRF_TOKEN .'='.
+ $parent->generateCSRFToken($user_id));
}
if ($data['MODE'] == "read") {
$data['GROUP_STATUS'] = $group['STATUS'];
@@ -3306,8 +3308,8 @@ EOD;
}
$head_string = "";
foreach ($page_defaults as $key => $default) {
- $head_string .= urlencode($key)."=".urlencode($head_vars[$key]).
- "\n\n";
+ $head_string .= urlencode($key) . "=" .
+ urlencode($head_vars[$key]) . "\n\n";
}
if (is_array($page)) { //template case
$page = base64_encode(serialize($page));