• Resolved Fibro Jedi

    (@fibrojedi)


    After a custom post type which was working fine suddenly stopped, I had a dig around and found MCM was throwing an error.

     PHP Fatal error:  Uncaught Error: Call to a member function mcm_query_vars_add_values() on null in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy.php:215
    Stack trace:
    #0 /home/username/public_html/wp-includes/class-wp-hook.php(308): WP_MCM_Taxonomy->mcm_pre_get_posts_front(Object(WP_Query))
    #1 /home/username/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
    #2 /home/username/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
    #3 /home/username/public_html/wp-includes/class-wp-query.php(1870): do_action_ref_array('pre_get_posts', Array)
    #4 /home/username/public_html/wp-includes/class-wp-query.php(3787): WP_Query->get_posts()
    #5 /home/username/public_html/wp-includes/class-wp.php(663): WP_Query->query(Array)
    #6 /home/username/public_html/wp-includes/class-wp.php(783): WP->query_posts()
    #7 /home/username/public_html/wp-includes/functions.php(1334): WP->main('')
    #8 /home/username/public_html/wp-blog-header.php(16): wp()
    #9 /home/username/public_html/index.php(17): require('/home/username...')
    #10 {main}
      thrown in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy.php on line 215

    Deactivating your plugin made my custom post type work again.

    If there is something I can do to fix this, or if it’s something I have caused do let me know! Otherwise, I’ll have to keep MCM deactivated until yous have a chance to update your plugin.

    Thanks!

    PS: While I don’t know if this error existed prior to the last MCM update, it’s only since then that I’ve had conflicts with my custom post type.

    • This topic was modified 1 year, 9 months ago by Fibro Jedi.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author DeBAAT

    (@debaat)

    Hai Fibro,

    Sorry to read you have an issue. Unfortunately, this is indeed a bug and I will fix it soon.

    In the mean time could you try to disable the option “Search Media Library” in the WP MCM Settings? The code you are referring to is only called when this checkbox is ticked.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Hey,

    Yes, on my offline version of my site, when I reactivate MCM, untick that setting then check back where I had the conflict with my custom post type, it works again.

    The issue was when using post filters (effectively searching with conditions), so I can see why your workaround does the trick.

    Thanks!

    Plugin Author DeBAAT

    (@debaat)

    Hai Fibro,

    The latest version should fix the issue. Would you be so kind as to test it and mark this issue as resolved?

    Thanks!

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Hi, I did the update, then re-enabled the option above. The error log now shows

    PHP Warning:  Undefined variable $t in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy_Admin.php on line 302
    [30-May-2023 13:34:07 UTC] PHP Warning:  Trying to access array offset on value of type null in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy_Admin.php on line 302
    [30-May-2023 14:27:47 UTC] PHP Warning:  Undefined array key "host" in /home/username/public_html/wp-includes/canonical.php on line 689
    [30-May-2023 14:27:47 UTC] PHP Warning:  Undefined array key "host" in /home/username/public_html/wp-includes/canonical.php on line 698
    [30-May-2023 14:27:47 UTC] PHP Warning:  Undefined array key "host" in /home/username/public_html/wp-includes/canonical.php on line 701
    [30-May-2023 14:43:38 UTC] PHP Warning:  Undefined variable $t in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy_Admin.php on line 302
    [30-May-2023 14:43:38 UTC] PHP Warning:  Trying to access array offset on value of type null in /home/username/public_html/wp-content/plugins/wp-media-category-management/include/taxonomy/class-WP_MCM_Taxonomy_Admin.php on line 302

    And the custom post type issue above still happens with that option on.

    At least it’s not a fatal error this time ??

    [edit]

    When the search media library option is on, I get this at the top of a post list I’ve searched:

    Array to string conversion in /path-to/wp-admin/edit.php on line 340

    It goes away again once disabled.

    The line with undefined variable: $t is line 230 is this:

    $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );

    I wasn’t sure exactly which variable it _should_ have been. I tried:

    $terms = wp_get_object_terms( $post->ID, $taxonomy, $cur_taxonomy['args'] );

    But that left the Array to String conversion error, but that is only reporting the end point error and I don’t know from the error log, which line of your code is outputting the supposed string?

    Don’t know if this helps at all, but I tried!

    • This reply was modified 1 year, 9 months ago by Fibro Jedi.
    • This reply was modified 1 year, 9 months ago by Fibro Jedi. Reason: First edit: adding things I've tried, second edit: typo correction
    Thread Starter Fibro Jedi

    (@fibrojedi)

    Additional: it’s not just custom post types. Whenever I filter normal posts (with that MCM option on) the list comes back blank.

    I deactivated my custom post types (which are managed through plugins) that behaviour (and error) still persists.

    I wanted to check that it wasn’t my CPTs interfering, but it’s not.

    Plugin Author DeBAAT

    (@debaat)

    Fixed the issue with the undefined variable.

    Unfortunately, I cannot reproduce the remaining issue. Can you please provide some more (error_log) information?

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Hey,

    Just to let you know, I’ve seen this and I’ve installed the latest version. I will let you know if I can reproduce the issue myself now.

    As you fixed $t, it might have auto-fixed the other issue. Either way, I’ll let you know so this isn’t left hanging around.

    Speak soon.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Okay, here’s what I tested

    1. With Search Media Library Option On Search a post list (it doesn’t matter whether it’s a standard post or a CPT, I checked both) in WP Admin
    2. Do the same again, but With Search Media Library Option Off

    In instance 1, the error below was logged, but not in instance 2.

    [11-Jul-2023 11:16:34 UTC] PHP Warning:  Array to string conversion in /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/fibrojedi.me.uk/wp-admin/edit.php on line 340
    [11-Jul-2023 11:16:34 UTC] PHP Warning:  Array to string conversion in /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/fibrojedi.me.uk/wp-admin/edit.php on line 477

    As not much else appeared in the error_log I went into your plugin file and found you have your own error constant. So I set that.
    Here’s the result of one search, which was

    • “Stoneshell”, in a custom post type, that returns two results.
      NB: Searching standard posts for a query also trips errors on edit.php on lines 340 and 477.
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::admin_init started with _GET: PR: Array
    (
        [s] => stoneshell
        [post_status] => all
        [post_type] => enemy
        [action] => -1
        [m] => 0
        [ffxiv_class] => 
        [ffxiv_difficulty_rank_filter] => 
        [paged] => 1
        [action2] => -1
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::admin_init started with _POST: PR: Array
    (
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::admin_init started with _REQUEST: PR: Array
    (
        [s] => stoneshell
        [post_status] => all
        [post_type] => enemy
        [action] => -1
        [m] => 0
        [ffxiv_class] => 
        [ffxiv_difficulty_rank_filter] => 
        [paged] => 1
        [action2] => -1
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::admin_init started with _FILES: PR: Array
    (
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Plugin::initialize started. MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Plugin::add_hooks_and_filters started. MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy::mcm_register_media_taxonomy taxonomy = category_media MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy::mcm_pre_get_posts is_search() = , is_archive() = , query->query =  PR: Array
    (
        [post_type] => post
        [post_status] => draft
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::wp_mcm_admin_menu started. MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: wp_mcm_freemius_pricing_url Changed pricing_url: PR: https://localhost/wp-admin/options-general.php?billing_cycle=annual&page=wp-mcm-pricing into my_pricing_url:
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::wp_mcm_check_upgrade started for option_version = 2.1.2! MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::wp_mcm_check_upgrade started for WP_MCM_VERSION_NUM = 2.1.2! MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Activate::init started. MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::wp_mcm_check_upgrade started for update_to_new_version = ! MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::wp_mcm_admin_init started. MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Admin::mcm_handle_notice_status wp_mcm_options = PR: Array
    (
        [wp_mcm_toggle_assign] => 1
        [wp_mcm_media_taxonomy_to_use] => category_media
        [wp_mcm_category_base] => category_media
        [wp_mcm_custom_taxonomy_name] => 
        [wp_mcm_custom_taxonomy_name_single] => 
        [wp_mcm_use_post_taxonomy] => 0
        [wp_mcm_search_media_library] => 1
        [wp_mcm_use_default_category] => 0
        [wp_mcm_default_media_category] => uncategorized
        [wp_mcm_default_post_category] => 
        [wp_mcm_use_gutenberg_filter] => 0
        [wp_mcm_notice_status] => 0
        [wp_mcm_notice_activation_date] => 1598531346
        [wp_mcm_version] => 2.1.2
        [wp_mcm_debug] => OPTION wp_mcm_media_taxonomy_to_use: category_media \n wp_mcm_media_taxonomy_to_use: category_media \n wp_mcm_default_media_category: uncategorized 
        [wp_mcm_flush_rewrite_rules] => 0
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy_Admin::mcm_request_admin taxonomy = category_media query_args =  PR: Array
    (
        [m] => 0
        [s] => stoneshell
        [paged] => 1
        [order] => 
        [orderby] => 
        [post_type] => enemy
        [posts_per_page] => 20
        [post_status] => 
        [perm] => 
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy::mcm_get_no_category_search Invalid request: No filter action.  MSG:  
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy_Admin::mcm_request_admin RETURN query_args =  PR: Array
    (
        [m] => 0
        [s] => stoneshell
        [paged] => 1
        [order] => 
        [orderby] => 
        [post_type] => enemy
        [posts_per_page] => 20
        [post_status] => 
        [perm] => 
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy::mcm_pre_get_posts is_search() = 1, is_archive() = , query->query =  PR: Array
    (
        [m] => 0
        [s] => stoneshell
        [paged] => 1
        [order] => 
        [orderby] => 
        [post_type] => enemy
        [posts_per_page] => 20
        [post_status] => 
        [perm] => 
    )
    
    [11-Jul-2023 11:25:17 UTC] :: WPMCM:: WP_MCM_Taxonomy::mcm_pre_get_posts mcm_taxonomy_category_to_find = ; query->query =  PR: Array
    (
        [m] => 0
        [s] => stoneshell
        [paged] => 1
        [order] => 
        [orderby] => 
        [post_type] => enemy
        [posts_per_page] => 20
        [post_status] => 
        [perm] => 
    )
    
    [11-Jul-2023 11:25:17 UTC] PHP Warning:  Array to string conversion in /mnt/1c88b8d1-c48e-4b2e-92b3-89e869e10559/fibrojedi.me.uk/wp-admin/edit.php on line 340

    The log does go on, but most of it appears to be an escaped list of all my categories, so I’m not sure if that would be helpful or not?

    Hope something here helps,

    Thanks.

    Plugin Author DeBAAT

    (@debaat)

    Thanks for the testing and reporting.

    I think I found the issue. In short: it is rediculous to search for an attachment when listing posts. So now I only search for attachments when not on an admin page.

    Would you be so kind as to test again and close the issue when it works?

    Thanks!

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Hurrah, well done!

    I updated MCM, then tested searching in the back office (just for completeness). Then I checked a standard post with an MCM shortcode, and lastly a CPT where I’ve used it.

    No errors at all.

    Thank you – and yes, I shall close it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Fatal Error After Last Update’ is closed to new replies.