summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-07-31 17:20:00 +0200
committerChristopher Smith <chris@jalakai.co.uk>2013-08-01 11:11:52 +0200
commit818d2283465b76931db168a9e2c72f2c0f004ecc (patch)
tree21aef09b4fdc9946c50c33422847aef9c13d5494 /inc
parent40960973d7ca45411e13e072595928d13534989e (diff)
downloadrpg-818d2283465b76931db168a9e2c72f2c0f004ecc.tar.gz
rpg-818d2283465b76931db168a9e2c72f2c0f004ecc.tar.bz2
Fix the useheading cache invalidation for hidden pages, add tests
This adds a new parameter to ft_backlinks() to ignore permissions which is needed for invalidating the cache of linking pages with useheading enabled. This also adds various test cases for ft_backlinks().
Diffstat (limited to 'inc')
-rw-r--r--inc/common.php2
-rw-r--r--inc/fulltext.php12
2 files changed, 9 insertions, 5 deletions
diff --git a/inc/common.php b/inc/common.php
index 1b4d9e8e4..bff6e80de 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1130,7 +1130,7 @@ function saveWikiText($id, $text, $summary, $minor = false) {
// if useheading is enabled, purge the cache of all linking pages
if(useHeading('content')) {
- $pages = ft_backlinks($id);
+ $pages = ft_backlinks($id, true);
foreach($pages as $page) {
$cache = new cache_renderer($page, wikiFN($page), 'xhtml');
$cache->removeCache();
diff --git a/inc/fulltext.php b/inc/fulltext.php
index 2f073acea..1afff25dd 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -125,17 +125,21 @@ function _ft_pageSearch(&$data) {
* Returns the backlinks for a given page
*
* Uses the metadata index.
+ *
+ * @param string $id The id for which links shall be returned
+ * @param bool $ignore_perms Ignore the fact that pages are hidden or read-protected
+ * @return array The pages that contain links to the given page
*/
-function ft_backlinks($id){
- $result = array();
-
+function ft_backlinks($id, $ignore_perms = false){
$result = idx_get_indexer()->lookupKey('relation_references', $id);
if(!count($result)) return $result;
// check ACL permissions
foreach(array_keys($result) as $idx){
- if(isHiddenPage($result[$idx]) || auth_quickaclcheck($result[$idx]) < AUTH_READ || !page_exists($result[$idx], '', false)){
+ if(($ignore_perms !== true && (
+ isHiddenPage($result[$idx]) || auth_quickaclcheck($result[$idx]) < AUTH_READ
+ )) || !page_exists($result[$idx], '', false)){
unset($result[$idx]);
}
}