Commit f258eede authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-3950

parent 3b5d8860
Loading
Loading
Loading
Loading
+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+26 −1
Original line number Diff line number Diff line
@@ -651,6 +651,31 @@ function get_cache_entry($codename, $cache_identifier, $special_cache_flags, $tt
    return $rets[0];
}

/**
 * Get a cache signature that can accurately represent what permissions a member will have.
 *
 * @return string Cache signature
 */
function permissive_groups_cache_signature()
{
    static $groups_cache = null;

    if ($groups_cache === null) {
        $actual_groups = filter_group_permissivity($GLOBALS['FORUM_DRIVER']->get_members_groups(get_member()));
        $m_zone = collapse_1d_complexity('zone_name', $GLOBALS['SITE_DB']->query_select('member_zone_access', array('zone_name'), array('member_id' => get_member())));
        $m_page = array_map('array_values', $GLOBALS['SITE_DB']->query_select('member_page_access', array('page_name', 'zone_name'), array('member_id' => get_member()), 'ORDER BY zone_name,page_name'));
        $m_privileges = array_map('array_values', $GLOBALS['SITE_DB']->query_select('member_privileges', array('privilege', 'the_page', 'module_the_name', 'category_name', 'the_value'), array('member_id' => get_member()), 'ORDER BY privilege,the_page,module_the_name,category_name,the_value'));
        $m_categories = array_map('array_values', $GLOBALS['SITE_DB']->query_select('member_category_access', array('module_the_name', 'category_name'), array('member_id' => get_member()), 'ORDER BY module_the_name,category_name'));
        if ((empty($m_zone)) && (empty($m_page)) && (empty($m_privileges)) && (empty($m_categories))) {
            $groups_cache = implode(',', array_map('strval', $actual_groups));
        } else {
            $groups_cache = json_encode(array($actual_groups, $m_zone, $m_page, $m_privileges, $m_categories));
        }
    }

    return $groups_cache;
}

/**
 * Ability to do multiple get_cache_entry at once, for performance reasons.
 *
@@ -673,7 +698,7 @@ function _get_cache_entries($dets, $special_cache_flags = null)
    require_code('temporal');
    $staff_status = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_STAFF_STATUS) !== 0)) ? ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) ? 1 : 0) : null;
    $member = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_MEMBER) !== 0)) ? get_member() : null;
    $groups = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0)) ? implode(',', array_map('strval', filter_group_permissivity($GLOBALS['FORUM_DRIVER']->get_members_groups(get_member())))) : '';
    $groups = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0)) ? permissive_groups_cache_signature() : '';
    $is_bot = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_BOT_STATUS) !== 0)) ? (is_null(get_bot_type()) ? 0 : 1) : null;
    $timezone = (($special_cache_flags !== null) && (($special_cache_flags & CACHE_AGAINST_TIMEZONE) !== 0)) ? get_users_timezone(get_member()) : '';

+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ function request_via_cron($codename, $map, $special_cache_flags, $tempcode)
        'c_map' => serialize($map),
        'c_staff_status' => (($special_cache_flags & CACHE_AGAINST_STAFF_STATUS) != 0) ? $GLOBALS['FORUM_DRIVER']->is_staff(get_member()) : null,
        'c_member' => (($special_cache_flags & CACHE_AGAINST_BOT_STATUS) != 0) ? get_member() : null,
        'c_groups' => (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) != 0) ? implode(',', array_map('strval', filter_group_permissivity($GLOBALS['FORUM_DRIVER']->get_members_groups(get_member())))) : '',
        'c_groups' => (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) != 0) ? permissive_groups_cache_signature() : '',
        'c_is_bot' => (($special_cache_flags & CACHE_AGAINST_BOT_STATUS) != 0) ? (is_null(get_bot_type()) ? 0 : 1) : null,
        'c_timezone' => (($special_cache_flags & CACHE_AGAINST_TIMEZONE) != 0) ? get_users_timezone(get_member()) : '',
        'c_store_as_tempcode' => $tempcode ? 1 : 0,
+2 −2
Original line number Diff line number Diff line
@@ -1183,7 +1183,7 @@ function do_block($codename, $map = null, $ttl = null)
                        require_code('temporal');
                        $staff_status = (($special_cache_flags & CACHE_AGAINST_STAFF_STATUS) !== 0) ? ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) ? 1 : 0) : null;
                        $member = (($special_cache_flags & CACHE_AGAINST_MEMBER) !== 0) ? get_member() : null;
                        $groups = (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0) ? implode(',', array_map('strval', filter_group_permissivity($GLOBALS['FORUM_DRIVER']->get_members_groups(get_member())))) : '';
                        $groups = (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0) ? permissive_groups_cache_signature() : '';
                        $is_bot = (($special_cache_flags & CACHE_AGAINST_BOT_STATUS) !== 0) ? (is_null(get_bot_type()) ? 0 : 1) : null;
                        $timezone = (($special_cache_flags & CACHE_AGAINST_TIMEZONE) !== 0) ? get_users_timezone(get_member()) : '';
                        put_into_cache($codename, $ttl, $cache_identifier, $staff_status, $member, $groups, $is_bot, $timezone, $cache, array_keys($LANGS_REQUESTED), array_keys($JAVASCRIPTS), array_keys($CSSS), true);
@@ -1255,7 +1255,7 @@ function do_block($codename, $map = null, $ttl = null)
                require_code('temporal');
                $staff_status = (($special_cache_flags & CACHE_AGAINST_STAFF_STATUS) !== 0) ? ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) ? 1 : 0) : null;
                $member = (($special_cache_flags & CACHE_AGAINST_MEMBER) !== 0) ? get_member() : null;
                $groups = (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0) ? implode(',', array_map('strval', filter_group_permissivity($GLOBALS['FORUM_DRIVER']->get_members_groups(get_member())))) : '';
                $groups = (($special_cache_flags & CACHE_AGAINST_PERMISSIVE_GROUPS) !== 0) ? permissive_groups_cache_signature() : '';
                $is_bot = (($special_cache_flags & CACHE_AGAINST_BOT_STATUS) !== 0) ? (is_null(get_bot_type()) ? 0 : 1) : null;
                $timezone = (($special_cache_flags & CACHE_AGAINST_TIMEZONE) !== 0) ? get_users_timezone(get_member()) : '';
                put_into_cache($codename, $info['ttl'], $cache_identifier, $staff_status, $member, $groups, $is_bot, $timezone, $cache, array_keys($LANGS_REQUESTED), $GLOBALS['OUTPUT_STREAMING'] ? array() : array_keys($JAVASCRIPTS), $GLOBALS['OUTPUT_STREAMING'] ? array() : array_keys($CSSS), true);