Page MenuHomeGitPull.it

WordPress MU - debug activated - crash
ActivePublic

Authored by valerio.bozzolan on Aug 24 2024, 17:48.
Tags
None
Referenced Files
F2334553: WordPress MU - debug activated - crash
Aug 24 2024, 17:48
Subscribers
None
Warning: Attempt to read property "roles" on bool in /home/sezionilocali/public_html/wp-content/themes/linuxit-wordpress-theme/inc/multisite.php on line 7
Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/sezionilocali/public_html/wp-content/themes/linuxit-wordpress-theme/inc/multisite.php:8 Stack trace: #0 /home/sezionilocali/public_html/wp-content/themes/linuxit-wordpress-theme/inc/multisite.php(8): in_array() #1 /home/sezionilocali/public_html/wp-includes/class-wp-hook.php(326): multisite_custom_css_map_meta_cap() #2 /home/sezionilocali/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters() #3 /home/sezionilocali/public_html/wp-includes/capabilities.php(842): apply_filters() #4 /home/sezionilocali/public_html/wp-includes/class-wp-user.php(782): map_meta_cap() #5 /home/sezionilocali/public_html/wp-includes/capabilities.php(985): WP_User->has_cap() #6 /home/sezionilocali/public_html/wp-includes/capabilities.php(877): user_can() #7 /home/sezionilocali/public_html/wp-includes/kses.php(2338): current_user_can() #8 /home/sezionilocali/public_html/wp-includes/class-wp-hook.php(324): kses_init() #9 /home/sezionilocali/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #10 /home/sezionilocali/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #11 /home/sezionilocali/public_html/wp-settings.php(700): do_action() #12 /home/sezionilocali/public_html/wp-config.php(99): require_once('...') #13 /home/sezionilocali/public_html/wp-load.php(50): require_once('...') #14 /home/sezionilocali/public_html/wp-blog-header.php(13): require_once('...') #15 /home/sezionilocali/public_html/index.php(17): require('...') #16 {main} thrown in /home/sezionilocali/public_html/wp-content/themes/linuxit-wordpress-theme/inc/multisite.php on line 8

Event Timeline

diff --git a/inc/multisite.php b/inc/multisite.php
index 83c9c97..8890c9d 100644
--- a/inc/multisite.php
+++ b/inc/multisite.php
@@ -4,11 +4,12 @@
 add_filter( 'map_meta_cap', 'multisite_custom_css_map_meta_cap', 20, 3 );
 function multisite_custom_css_map_meta_cap( $caps, $cap, $user_id ) {
        $user_meta = get_userdata($user_id);
-       $user_roles = $user_meta->roles;
-       if ( in_array("administrator", $user_roles) ){
-               $caps = array( 'edit_theme_options' );
+       if( $user_meta ) {
+               $user_roles = $user_meta->roles;
+               if ( in_array("administrator", $user_roles) ){
+                       $caps[] = 'edit_theme_options';
+               }
        }
-
        return $caps;
 }
Deprecated: Creation of dynamic property Stonehenge_Plugin::$parsley is deprecated in /home/sezionilocali/public_html/wp-content/plugins/stonehenge-em-osm/stonehenge/class-core.php on line 130
diff --git a/inc/multisite.php b/inc/multisite.php
index 83c9c97..8890c9d 100644
--- a/inc/multisite.php
+++ b/inc/multisite.php
@@ -4,11 +4,12 @@
 add_filter( 'map_meta_cap', 'multisite_custom_css_map_meta_cap', 20, 3 );
 function multisite_custom_css_map_meta_cap( $caps, $cap, $user_id ) {
        $user_meta = get_userdata($user_id);
-       $user_roles = $user_meta->roles;
-       if ( in_array("administrator", $user_roles) ){
-               $caps = array( 'edit_theme_options' );
+       if( $user_meta ) {
+               $user_roles = $user_meta->roles;
+               if ( in_array("administrator", $user_roles) ){
+                       $caps[] = 'edit_theme_options';
+               }
        }
-
        return $caps;
 }
diff --git a/inc/multisite.php b/inc/multisite.php
index 83c9c97..8890c9d 100644
--- a/inc/multisite.php
+++ b/inc/multisite.php
@@ -4,11 +4,12 @@
 add_filter( 'map_meta_cap', 'multisite_custom_css_map_meta_cap', 20, 3 );
 function multisite_custom_css_map_meta_cap( $caps, $cap, $user_id ) {
        $user_meta = get_userdata($user_id);
-       $user_roles = $user_meta->roles;
-       if ( in_array("administrator", $user_roles) ){
-               $caps = array( 'edit_theme_options' );
+       if( $user_meta ) {
+               $user_roles = $user_meta->roles;
+               if ( in_array("administrator", $user_roles) ){
+                       $caps[] = 'edit_theme_options';
+               }
        }
-
        return $caps;
 }

https://gitlab.com/ItalianLinuxSociety/linuxit-wordpress-theme/-/compare/d23940b505fe2b8a0d971e655e76f1e710f8758b...565355e8ecad68e8fd07fb74a20516e5ce503fab