Support » Plugin: Cache-Control » 500s on redirects? Call to a member function get_queried_object_id() on null

  • We are seeing 500s on some, but not all, permanent redirects in our production environment with the cache-control plugin enabled. Here’s what we see:

    
    2018/12/07 17:22:29 [error] 18523#18523: *2917 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function get_queried_object_id() on null in WEBROOT/wp-includes/query.php:60
    Stack trace:
    #0 WEBROOT/wp-includes/class-wp-query.php(3989): get_queried_object_id()
    #1 WEBROOT/wp-includes/class-wp-query.php(3100): WP_Query->setup_postdata(Object(WP_Post))
    #2 WEBROOT/wp-content/plugins/cache-control/cache-control.php(185): WP_Query->the_post()
    #3 WEBROOT/wp-content/plugins/cache-control/cache-control.php(244): cache_control_is_future_now_maxtime(86400)
    #4 WEBROOT/wp-content/plugins/cache-control/cache-control.php(380): cache_control_build_directive_from_option('redirect_perman...')
    #5 WEBROOT/wp-includes/class-wp-hook.php(286): cache_control_handle_redirects(301, 'https://www.was...')
    #6 WEBROOT/wp-include" while reading response header from upstream, client: 127.0.0.1, server: HOSTNAME, request: "GET /PATH/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "HOSTNAME"
    2018/12/07 17:22:46 [error] 18523#18523: *3297 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function get_queried_object_id() on null in WEBROOT/wp-includes/query.php:60
    Stack trace:
    #0 WEBROOT/wp-includes/class-wp-query.php(3989): get_queried_object_id()
    #1 WEBROOT/wp-includes/class-wp-query.php(3100): WP_Query->setup_postdata(Object(WP_Post))
    #2 WEBROOT/wp-content/plugins/cache-control/cache-control.php(185): WP_Query->the_post()
    #3 WEBROOT/wp-content/plugins/cache-control/cache-control.php(244): cache_control_is_future_now_maxtime(86400)
    #4 WEBROOT/wp-content/plugins/cache-control/cache-control.php(380): cache_control_build_directive_from_option('redirect_perman...')
    #5 WEBROOT/wp-includes/class-wp-hook.php(286): cache_control_handle_redirects(301, 'https://www.was...')
    #6 WEBROOT/wp-include" while reading response header from upstream, client: 127.0.0.1, server: HOSTNAME, request: "GET /PATH/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "HOSTNAME"

    Haven’t validated this yet, but I wonder if adding redirect_permanent to the list of option_names in #239-243 might help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • We’re also seeing 500s with exactly the same error, on permanent redirects created with Yoast.

    Adding redirect_permanent to row #239-243 in cache-control.php indeed fixes the problem, however I’m not sure if that’s the best way to solve this. Did you look into this more?

    The fix works well for us in production.

    Plugin Author Dan

    (@geekysoft)

    Could you please provide more information on the non-core redirects you guys are using? How are they setup and used? Is there really no object in the query?

    They are redirects created with the Yoast SEO plugin. It automatically creates them when a post’s URL changes. There is really no object in the query, as far as I can tell.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.