Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function getRequest() on null is RequestPanel.php file #372

Open
vasyakrg opened this issue Apr 12, 2019 · 12 comments
Open
Labels

Comments

@vasyakrg
Copy link

Fatal error: Uncaught Error: Call to a member function getRequest() on null in /var/www/yii2/vendor/yiisoft/yii2-debug/src/panels/**RequestPanel.php on line 59**

Call Stack:
    0.0016     351728   1. {main}() /var/www/yii2/vendor/codeception/codeception/codecept:0
    0.5448    1842688   2. Codeception\Application->run(???, ???) /var/www/yii2/vendor/codeception/codeception/codecept:43
    0.5449    1842688   3. Codeception\Application->run(???, ???) /var/www/yii2/vendor/codeception/codeception/src/Codeception/Application.php:108

Error: Call to a member function getRequest() on null in /var/www/yii2/vendor/yiisoft/yii2-debug/src/panels/RequestPanel.php on line 59

Call Stack:
    0.0016     351728   1. {main}() /var/www/yii2/vendor/codeception/codeception/codecept:0
    0.5448    1842688   2. Codeception\Application->run(???, ???) /var/www/yii2/vendor/codeception/codeception/codecept:43
    0.5449    1842688   3. Codeception\Application->run(???, ???) /var/www/yii2/vendor/codeception/codeception/src/Codeception/Application.php:108
   18.4747    5267328   4. yii\log\Logger->flush(???) /var/www/yii2/vendor/yiisoft/yii2/log/Logger.php:0
   18.4747    5267328   5. yii\log\Dispatcher->dispatch(???, ???) /var/www/yii2/vendor/yiisoft/yii2/log/Logger.php:177
   18.4747    5267328   6. yii\debug\LogTarget->collect(???, ???) /var/www/yii2/vendor/yiisoft/yii2/log/Dispatcher.php:189
   18.4747    5267328   7. yii\debug\LogTarget->export() /var/www/yii2/vendor/yiisoft/yii2-debug/src/LogTarget.php:130
   18.4966    5295024   8. yii\debug\panels\RequestPanel->save() /var/www/yii2/vendor/yiisoft/yii2-debug/src/LogTarget.php:6

Additional info

Q A
Yii version 2.0.17
PHP version PHP 7.1.27 (cli)
Operating system Debian (docker)
codeception/codeception 2.5.5
yiisoft/yii2-debug 2.1.1
@vasyakrg
Copy link
Author

decision:

on file: vendor/yiisoft/yii2-debug/src/panels/RequestPanel.php
before: line 59 -
$headers = Yii::$app->getRequest()->getHeaders();
add
if (Yii::$app === null) {return '';}

@vasyakrg vasyakrg changed the title Call to a member function getRequest() on null Call to a member function getRequest() on null is RequestPanel.php file Apr 12, 2019
@samdark samdark transferred this issue from yiisoft/yii2 Apr 12, 2019
@yii-bot
Copy link

yii-bot commented Apr 12, 2019

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

This is an automated comment, triggered by adding the label status:need more info.

@machour machour added the expired Information requested was not provided in two weeks. label May 9, 2019
@yii-bot
Copy link

yii-bot commented May 9, 2019

It has been 2 or more weeks with no response on our request for more information.
In order for our issue tracker to be effective, we are closing this issue.

If you want it to be reopened again, feel free to supply us with the requested information.

Thanks!

This is an automated comment, triggered by adding the label expired.

@yii-bot yii-bot closed this as completed May 9, 2019
@schmunk42
Copy link
Contributor

schmunk42 commented Jun 3, 2019

I ran into the same issue, see https://travis-ci.org/dmstr/phd5-app/builds/540910183#L3086

The root cause was a "functional", which did not create any request but checked a version file. My solution was to move the test to the CLI suite. (VersionCept)

But nonetheless it's something we should care about, since all tests are green, but the pipeline still fails due to the error thrown under the hood.


[addon] My changes did not really fix the issue, still investigating...

@schmunk42
Copy link
Contributor

schmunk42 commented Jun 3, 2019

So my fix or better workaround is this: dmstr/phd5-app@5449726 - disabling the debug module in tests.

I had the issue also in unit tests.

Reopening ... how to proceed, do you need additional info?

@schmunk42 schmunk42 reopened this Jun 3, 2019
@samdark
Copy link
Member

samdark commented Jun 3, 2019

Yes. Is that Codeception-specific?

@samdark samdark added type:bug Bug and removed expired Information requested was not provided in two weeks. status:need more info labels Jun 3, 2019
@machour
Copy link
Member

machour commented Jun 4, 2019

Had the exact same issue today, running g codeception too

@schmunk42
Copy link
Contributor

Yes. Is that Codeception-specific?

Yes, I had this after upgrading from 2.3 to 2.5

@SamMousa
Copy link
Contributor

SamMousa commented Jun 4, 2019

I just wrote a long post about register_shutdown_function... and then not posted it because it was wrong
Turns out we already handle it: https://github.com/Codeception/Codeception/blob/3.0/src/Codeception/Lib/Connector/Yii2.php#L267

The source of the issue is register_shutdown_function which is (imo) a design flaw of Yii logging. The logging modules make assumptions about the state of the system which they shouldn't.
By definition the shutdown function is always called and therefore no assumptions on the state should be made.

@schmunk42 can you check if the logger is getting replaced properly.

Side note: instead of overriding the logger class, we could probably do something like this:

namespace yii\log {
    function register_shutdown_function() {
        codecept_debug('Mocked register_shutdown_function called');
    }

@schmunk42
Copy link
Contributor

Like mentioned from @SamMousa using

namespace yii\log {

    function register_shutdown_function()
    {
        // Stop calling register_shutdown_function
    }

}

in _bootstrap.php (I put it in unit/ and functional/) is a better fix for this.

schmunk42 added a commit to dmstr/phd5-app that referenced this issue Jun 4, 2019
@SamMousa
Copy link
Contributor

SamMousa commented Jun 4, 2019

I'm putting this in codeception as well, since it's a better fix.

@schmunk42
Copy link
Contributor

I'm putting this in codeception as well, since it's a better fix.

Would be nice to see this in 2.x, since upgrading to 3.x raised even more issues.

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

No branches or pull requests

6 participants