diff --git a/build/index.php b/build/index.php index c792e35..351ffd6 100644 --- a/build/index.php +++ b/build/index.php @@ -1055,6 +1055,7 @@ function render_sidebar($pageindex, $root_pagename = "") +error_log("Initialising redirect page support"); register_module([ "name" => "Redirect pages", "version" => "0.1", @@ -1063,6 +1064,7 @@ register_module([ "id" => "feature-redirect", "code" => function() { register_save_preprocessor(function(&$index_entry, &$pagedata) { + error_log("Running redirect check"); $matches = []; if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1) { @@ -1230,10 +1232,11 @@ register_module([ if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled !$settings->editing or// or editing is disabled - ( // the page exists and is protected and the user isn't an admin - isset($pageindex->$page) and - $pageindex->$page->protect and - !$env->is_admin + ( + isset($pageindex->$page) and // the page exists + isset($pageindex->$page->protect) and // the protect property exists + $pageindex->$page->protect and // the protect property is true + !$env->is_admin // the user isn't an admin ) ) { @@ -1284,7 +1287,11 @@ register_module([ exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); } $page = $env->page; - if($pageindex->$page->protect and !$env->is_admin) + if(( + isset($pageindex->$page) and + isset($pageindex->page->protect) and + $pageindex->$page->protect + ) and !$env->is_admin) { http_response_code(403); header("refresh: 5; url=index.php?page=$env->page"); diff --git a/module_index.json b/module_index.json index c4ebb41..1ba1523 100644 --- a/module_index.json +++ b/module_index.json @@ -41,7 +41,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.", "id": "feature-redirect", - "lastupdate": 1443871356, + "lastupdate": 1443872212, "optional": false }, { @@ -68,7 +68,7 @@ "author": "Starbeamrainbowlabs", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "id": "page-edit", - "lastupdate": 1443871529, + "lastupdate": 1443872342, "optional": false }, { diff --git a/modules/feature-redirect.php b/modules/feature-redirect.php index 264bfda..0b55d9e 100644 --- a/modules/feature-redirect.php +++ b/modules/feature-redirect.php @@ -1,4 +1,5 @@ "Redirect pages", "version" => "0.1", @@ -7,6 +8,7 @@ register_module([ "id" => "feature-redirect", "code" => function() { register_save_preprocessor(function(&$index_entry, &$pagedata) { + error_log("Running redirect check"); $matches = []; if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1) { diff --git a/modules/page-edit.php b/modules/page-edit.php index 0cfcb47..bf928f3 100644 --- a/modules/page-edit.php +++ b/modules/page-edit.php @@ -39,10 +39,11 @@ register_module([ if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled !$settings->editing or// or editing is disabled - ( // the page exists and is protected and the user isn't an admin - isset($pageindex->$page) and - $pageindex->$page->protect and - !$env->is_admin + ( + isset($pageindex->$page) and // the page exists + isset($pageindex->$page->protect) and // the protect property exists + $pageindex->$page->protect and // the protect property is true + !$env->is_admin // the user isn't an admin ) ) { @@ -93,7 +94,11 @@ register_module([ exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); } $page = $env->page; - if($pageindex->$page->protect and !$env->is_admin) + if(( + isset($pageindex->$page) and + isset($pageindex->page->protect) and + $pageindex->$page->protect + ) and !$env->is_admin) { http_response_code(403); header("refresh: 5; url=index.php?page=$env->page"); @@ -135,9 +140,11 @@ register_module([ $pageindex->$page->lasteditor = utf8_encode("anonymous"); + var_dump($save_preprocessors); // Execute all the preprocessors foreach($save_preprocessors as $func) { + error_log("Executing handler"); $func($pageindex->$page, $pagedata); }