最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Plugin error "array_key_exists(): The first argument should be either a string or an integer"

programmeradmin4浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

Checking the Query Monitor, it's throwing out this error,

array_key_exists(): The first argument should be either a string or an integer

which relates to this function:

public function lsx_team_scporder_get_terms_orderby( $orderby, $args ) {
    if ( is_admin() )
        return $orderby;

    $tags = $this->get_lsx_team_scporder_options_tags();

    if ( ! isset( $args['taxonomy'] ) )
        return $orderby;

    $taxonomy = $args['taxonomy'];
    if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 )
        $taxonomy = $taxonomy[0];
    if ( ! array_key_exists($taxonomy, $tags ) )
        return $orderby;

    $orderby = 't.lsx_team_term_order';
    return $orderby;
}

Why is it throwing out that error?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

Checking the Query Monitor, it's throwing out this error,

array_key_exists(): The first argument should be either a string or an integer

which relates to this function:

public function lsx_team_scporder_get_terms_orderby( $orderby, $args ) {
    if ( is_admin() )
        return $orderby;

    $tags = $this->get_lsx_team_scporder_options_tags();

    if ( ! isset( $args['taxonomy'] ) )
        return $orderby;

    $taxonomy = $args['taxonomy'];
    if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 )
        $taxonomy = $taxonomy[0];
    if ( ! array_key_exists($taxonomy, $tags ) )
        return $orderby;

    $orderby = 't.lsx_team_term_order';
    return $orderby;
}

Why is it throwing out that error?

Share Improve this question edited Mar 27, 2020 at 23:56 Peter Mortensen 2682 silver badges10 bronze badges asked Apr 24, 2018 at 13:05 DemonixDemonix 613 silver badges12 bronze badges 1
  • I got this error today (2020-03-27) after updating WordPress to 5.3.2 (using theme "Responsive"). It happened on submitting updates to an existing blog post. It seems to be theme specific (and updating to the new version of the theme released today did not fix the problem). The workaround is to change to another theme (at least during adding/changing content) - I used the official "Twenty Twenty" theme. – Peter Mortensen Commented Mar 27, 2020 at 22:40
Add a comment  | 

1 Answer 1

Reset to default 0

From the php manual the array_key_exists() function takes as first argument "any value possible for an array index.", again looking up for arrays in the docs we can get that "The key can either be an integer or a string. The value can be of any type.", which also corresponds to the error you see from the Query Monitor.

Meaning that the $taxonomy variable that is passing to the array_key_exists() is not either a string or integer.

You can debug the $taxonomy variable, by making a var_dump($taxonomy);.

Hope, that helps.

发布评论

评论列表(0)

  1. 暂无评论