• I have an error in my network wordpress. I have 3 sites on my network, the first one without favorites, the other with favorites. And i have some issue

    First in the function get_user_favorites_count

    Warning: Undefined array key “site_id” in …/favorites/app/Helpers.php on line 96

    I fix this

    if ( $site_favorites['site_id'] == $site_id && isset($site_favorites['posts']) ) return $site_favorites['posts'];

    with

    if ( !empty($site_favorites['site_id']) && $site_favorites['site_id'] == $site_id && isset($site_favorites['posts']) ) return $site_favorites['posts'];

    And a second issue with the_favorites_button
    Warning: Undefined array key “site_id” in /var/www/html/wordpress/toulouse-attractivité-mb/assets/plugins/favorites/app/Helpers.php on line 113

    I fix this

    if ( $site_favorites['site_id'] !== $site_id ) continue;

    with

    if ( !empty($site_favorites['site_id']) && $site_favorites['site_id'] !== $site_id ) continue;

    This modification fix the warning but trigger an error

    Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /var/www/html/wordpress/toulouse-attractivité-mb/assets/plugins/favorites/app/Entities/User/UserRepository.php:189 Stack trace: #0 /var/www/html/wordpress/toulouse-attractivité-mb/assets/plugins/favorites/app/Entities/User/UserRepository.php(189): in_array()

    I fix this

    if ( in_array($post_id, $favorites) ) return true;

    with

    if ( is_array( $favorites) && in_array($post_id, $favorites) ) return true;

    And after this modification, everything work fine.

    Maybe I miss something, a setting to avoid this problem, but if not, maybe it’s should be a good idea to solve this issue

  • The topic ‘One site without favoris in network cause misfunction for other site’ is closed to new replies.