Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Functions are called incorrectly in Server_instrumentation.php #32

Description

@Tessachu

I get these errors in a continuous loop while debug is turned on. I had to add some code to my WP install in the "_doing_it_wrong" function to find out the culprit, and it was this plugin. Here's a snippet:

[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_page was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_single was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_category was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_home was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_archive was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_404 was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674

Line 33 of the file in question is the if-statement within this function:

function endRequest()
    {
        if (is_page() || is_single() || is_category() || is_home() || is_archive() || is_404())
        {
            $url = $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
            $requestName = Common::getPageTitle();
            $startTime = $_SERVER["REQUEST_TIME"];
            $duration = floatval(timer_stop(0, 3)) * 1000;
            $this->_telemetryClient->trackRequest($requestName, $url, $startTime, $duration, http_response_code(), !is_404());

            // Flush all telemetry items
            $this->_telemetryClient->flush();
        }
    }

I don't know why, when, or where "endRequest" is being called, or why it's doing so before the query is run, but it seems kind of important...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions