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

Functions are called incorrectly in Server_instrumentation.php #32

Open
Tessachu opened this issue Apr 6, 2020 · 0 comments
Open

Functions are called incorrectly in Server_instrumentation.php #32

Tessachu opened this issue Apr 6, 2020 · 0 comments

Comments

@Tessachu
Copy link

Tessachu commented Apr 6, 2020

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...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant