NewPath-Consulting / Wild-Apricot-Press

The core Wild Apricot Press (WAP) plugin.
https://newpathconsulting.com/wap
GNU General Public License v3.0
3 stars 1 forks source link

Fatal error being thrown when accessing a protected page on support.newpathconsulting.com #136

Open asirota opened 1 year ago

asirota commented 1 year ago

To simulate error try logging in with MPG credentials support@newpathconsulting.com/

the membership level and group sync just fine to the account in WordPress

But ALL pages whether they have access control or not yield this error:

Fatal error: Uncaught Error: array_key_exists(): Argument #2 ($array) must be of type array, string given
in /homepages/0/d91623022/htdocs/clickandbuilds/startuphaven/wp-content/plugins/newpath-wildapricot-press/src/class-wa-integration.php on line 1865

Call stack:

array_key_exists()
wp-content/plugins/newpath-wildapricot-press/src/class-wa-integration.php:1865
WAWP\WA_Integration::get_wa_post_meta()
wp-content/plugins/newpath-wildapricot-press/src/class-wa-integration.php:1537
WAWP\WA_Integration::create_wa_login_logout()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-includes/nav-menu-template.php:267
wp_nav_menu()
wp-content/themes/twentytwentyone/template-parts/header/site-nav.php:27
require()
wp-includes/template.php:785
load_template()
wp-includes/template.php:718
locate_template()
wp-includes/general-template.php:204
get_template_part()
wp-content/themes/twentytwentyone/template-parts/header/site-header.php:19
require()
wp-includes/template.php:785
load_template()
wp-includes/template.php:718
locate_template()
wp-includes/general-template.php:204
get_template_part()
wp-content/themes/twentytwentyone/header.php:28
require_once()
wp-includes/template.php:783
load_template()
wp-includes/template.php:718
locate_template()
wp-includes/general-template.php:48
get_header()
wp-content/themes/twentytwentyone/page.php:12
include()
wp-includes/template-loader.php:106
require_once()
wp-blog-header.php:19
require()
index.php:17
asirota commented 1 year ago

It appears that WAP processes page in a menu bar differently than pages not in a menu bar. So when a page is in a menu bar access control is checked and the current code doesn't check the access control properly. The access control features for pages/post NOT in a menu bar work just fine.

function get_wa_post_meta() expects an array to be passed into it holding the metadata of a post but currently a post ID is being sent into it and thus line 1882 throws an error when trying to see if an array key exists in a string

    if (array_key_exists(self::RESTRICTED_GROUPS, $meta)) {
            $restricted_groups = $meta[self::RESTRICTED_GROUPS][0];
        }
        if (array_key_exists(self::RESTRICTED_LEVELS, $meta)) {
            $restricted_levels = $meta[self::RESTRICTED_LEVELS][0];
        }
asirota commented 1 year ago

See this release to test a fix for this issue

https://github.com/NewPath-Consulting/Wild-Apricot-Press/releases/download/1.0.2b2/newpath-wildapricot-press-1.0.2b2.zip