Steps to reproduce

$ composer create-project drupal-composer/drupal-project:8.x-dev d9readiness --no-interaction
$ cd d9readiness
$ composer require 'drupal/upgrade_status:^1.0'
$ composer require 'drupal/redirect:1.3'

Install Drupal, Upgrade Status and Redirect modules (in Drupal). Go to admin/reports/upgrade, check checkbox in Redirect module's row, submit the form with the “Scan selected” button, see exception thrown.

Original report

Running the scan against Redirect 8.x-1.3 returns an AJAX HTTP error. Running it agains the other modules on our site works fine. Not sure if this is a problem with Redirect only, but it's so far the only one I've run into the error with. I'm running PHP 7.2.15 and Drupal 8.7.2 Here is the text of the error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=9&op=do_nojs&op=do
StatusText: OK
ResponseText: 
( ! ) Warning: Uncaught PHPStan\Broker\ClassAutoloadingException: Class Symfony\Component\Validator\ExecutionContextInterface not found and could not be autoloaded. in /Users/nancyrackleff/Sites/drupal-project/vendor/phpstan/phpstan/src/Broker/Broker.php:358
Stack trace:
#0 [internal function]: PHPStan\Broker\Broker->PHPStan\Broker\{closure}('Symfony\\Compone...')
#1 /Users/nancyrackleff/Sites/drupal-project/web/modules/contrib/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php(23): spl_autoload_call('Symfony\\Compone...')
#2 /Users/nancyrackleff/Sites/drupal-project/vendor/composer/ClassLoader.php(444): include('/Users/nancyrac...')
#3 /Users/nancyrackleff/Sites/drupal-project/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Users/nancyrac...')
#4 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\redirect...')
#5 [internal function]: spl_autoload_call('Drupal\\redirect...')
#6 /Users/nancyrackleff/Sites/drupal-project/vendor/phpstan/phpstan/src/Broker/Broker.php in /Users/nancyrackleff/Sites/drupal-project/vendor/phpstan/phpstan/src/Broker/Broker.php on line 358
Call Stack
#TimeMemoryFunctionLocation
10.0011403960{main}(  ).../index.php:0
20.0017525960Drupal\Core\DrupalKernel->handle(  ).../index.php:19
30.00631569232Stack\StackedHttpKernel->handle(  ).../DrupalKernel.php:693
40.00631569232Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(  ).../StackedHttpKernel.php:23
50.00631569928Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(  ).../NegotiationMiddleware.php:52
60.00631569928Drupal\Core\StackMiddleware\KernelPreHandle->handle(  ).../ReverseProxyMiddleware.php:47
70.00791970544Drupal\Core\StackMiddleware\Session->handle(  ).../KernelPreHandle.php:47
80.00942090080Symfony\Component\HttpKernel\HttpKernel->handle(  ).../Session.php:57
90.00942090496Symfony\Component\HttpKernel\HttpKernel->handleRaw(  ).../HttpKernel.php:68
100.02813227392Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}(  ).../HttpKernel.php:151
110.02813227392Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(  ).../EarlyRenderingControllerWrapperSubscriber.php:97
120.02813229928Drupal\Core\Render\Renderer->executeInRenderContext(  ).../EarlyRenderingControllerWrapperSubscriber.php:124
130.02813230280Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}(  ).../Renderer.php:582
140.02813230280call_user_func_array:{/Users/nancyrackleff/Sites/drupal-project/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}
(  ).../EarlyRenderingControllerWrapperSubscriber.php:123
150.02813230672Drupal\system\Controller\BatchController->batchPage(  ).../EarlyRenderingControllerWrapperSubscriber.php:123
160.02813230672_batch_page(  ).../BatchController.php:55
170.03544727048_batch_do(  ).../batch.inc:93
180.03544727048_batch_process(  ).../batch.inc:137
190.03614813280Drupal\upgrade_status\Form\UpgradeStatusForm::parseProject(  ).../batch.inc:295
200.52105812440Drupal\upgrade_status\DeprecationAnalyser->analyse(  ).../UpgradeStatusForm.php:434
213.246324114104Drupal\upgrade_status\DeprecationAnalyser->runPhpStan(  ).../DeprecationAnalyser.php:182
223.266524656864PHPStan\Command\AnalyseApplication->analyse(  ).../DeprecationAnalyser.php:345
233.266824657608PHPStan\Analyser\Analyser->analyse(  ).../AnalyseApplication.php:86
243.835816063704PHPStan\Analyser\NodeScopeResolver->processNodes(  ).../Analyser.php:191
253.835816063704PHPStan\Analyser\NodeScopeResolver->processStmtNode(  ).../NodeScopeResolver.php:178
263.835816064216PHPStan\Analyser\NodeScopeResolver->processStmtNodes(  ).../NodeScopeResolver.php:410
273.836016064168PHPStan\Analyser\NodeScopeResolver->processStmtNode(  ).../NodeScopeResolver.php:226
283.836016064168PHPStan\Analyser\Analyser->PHPStan\Analyser\{closure}(  ).../NodeScopeResolver.php:291
293.836016064120PHPStan\Rules\Deprecations\ImplementationOfDeprecatedInterfaceRule->processNode(  ).../Analyser.php:154
303.836016064232PHPStan\Broker\Broker->getClass(  ).../ImplementationOfDeprecatedInterfaceRule.php:44
313.836016064232PHPStan\Broker\Broker->hasClass(  ).../Broker.php:258
323.836116065032class_exists
(  ).../Broker.php:363
333.836116065128spl_autoload_call
(  ).../Broker.php:363
343.836116065224Composer\Autoload\ClassLoader->loadClass(  ).../Broker.php:363
353.836116065384Composer\Autoload\includeFile(  ).../ClassLoader.php:322
363.836116066296include( '/Users/nancyrackleff/Sites/drupal-project/web/modules/contrib/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php' ).../ClassLoader.php:444
( ! ) Fatal error: Declaration of Drupal\redirect\Plugin\Validation\Constraint\SourceLinkTypeConstraint::initialize(Symfony\Component\Validator\ExecutionContextInterface $context) must be compatible with Symfony\Component\Validator\ConstraintValidatorInterface::initialize(Symfony\Component\Validator\Context\ExecutionContextInterface $context) in /Users/nancyrackleff/Sites/drupal-project/web/modules/contrib/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php on line 23
Call Stack
#TimeMemoryFunctionLocation
10.0011403960{main}(  ).../index.php:0
20.0017525960Drupal\Core\DrupalKernel->handle(  ).../index.php:19
30.00631569232Stack\StackedHttpKernel->handle(  ).../DrupalKernel.php:693
40.00631569232Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(  ).../StackedHttpKernel.php:23
50.00631569928Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(  ).../NegotiationMiddleware.php:52
60.00631569928Drupal\Core\StackMiddleware\KernelPreHandle->handle(  ).../ReverseProxyMiddleware.php:47
70.00791970544Drupal\Core\StackMiddleware\Session->handle(  ).../KernelPreHandle.php:47
80.00942090080Symfony\Component\HttpKernel\HttpKernel->handle(  ).../Session.php:57
90.00942090496Symfony\Component\HttpKernel\HttpKernel->handleRaw(  ).../HttpKernel.php:68
100.02813227392Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}(  ).../HttpKernel.php:151
110.02813227392Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(  ).../EarlyRenderingControllerWrapperSubscriber.php:97
120.02813229928Drupal\Core\Render\Renderer->executeInRenderContext(  ).../EarlyRenderingControllerWrapperSubscriber.php:124
130.02813230280Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}(  ).../Renderer.php:582
140.02813230280call_user_func_array:{/Users/nancyrackleff/Sites/drupal-project/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}
(  ).../EarlyRenderingControllerWrapperSubscriber.php:123
150.02813230672Drupal\system\Controller\BatchController->batchPage(  ).../EarlyRenderingControllerWrapperSubscriber.php:123
160.02813230672_batch_page(  ).../BatchController.php:55
170.03544727048_batch_do(  ).../batch.inc:93
180.03544727048_batch_process(  ).../batch.inc:137
190.03614813280Drupal\upgrade_status\Form\UpgradeStatusForm::parseProject(  ).../batch.inc:295
200.52105812440Drupal\upgrade_status\DeprecationAnalyser->analyse(  ).../UpgradeStatusForm.php:434
213.246324114104Drupal\upgrade_status\DeprecationAnalyser->runPhpStan(  ).../DeprecationAnalyser.php:182
223.266524656864PHPStan\Command\AnalyseApplication->analyse(  ).../DeprecationAnalyser.php:345
233.266824657608PHPStan\Analyser\Analyser->analyse(  ).../AnalyseApplication.php:86
243.835816063704PHPStan\Analyser\NodeScopeResolver->processNodes(  ).../Analyser.php:191
253.835816063704PHPStan\Analyser\NodeScopeResolver->processStmtNode(  ).../NodeScopeResolver.php:178
263.835816064216PHPStan\Analyser\NodeScopeResolver->processStmtNodes(  ).../NodeScopeResolver.php:410
273.836016064168PHPStan\Analyser\NodeScopeResolver->processStmtNode(  ).../NodeScopeResolver.php:226
283.836016064168PHPStan\Analyser\Analyser->PHPStan\Analyser\{closure}(  ).../NodeScopeResolver.php:291
293.836016064120PHPStan\Rules\Deprecations\ImplementationOfDeprecatedInterfaceRule->processNode(  ).../Analyser.php:154
303.836016064232PHPStan\Broker\Broker->getClass(  ).../ImplementationOfDeprecatedInterfaceRule.php:44
313.836016064232PHPStan\Broker\Broker->hasClass(  ).../Broker.php:258
323.836116065032class_exists
(  ).../Broker.php:363
333.836116065128spl_autoload_call
(  ).../Broker.php:363
343.836116065224Composer\Autoload\ClassLoader->loadClass(  ).../Broker.php:363
353.836116065384Composer\Autoload\includeFile(  ).../ClassLoader.php:322
363.836116066296include( '/Users/nancyrackleff/Sites/drupal-project/web/modules/contrib/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php' ).../ClassLoader.php:444

Comments

nrackleff created an issue. See original summary.

gábor hojtsy’s picture

Title: AJAX HTTP error when scanning Redirect 8.x-1.3 » Uncaught PHPStan\Broker\ClassAutoloadingException with Redirect 8.x-1.3

Retitled. The module theoretically has error recovery for fatal PHP errors, but it does not work for this case. We should up our recovery potential if we can recover from this issue in PHP itself (it. catch the exception and save it instead of failing entirely).

gábor hojtsy’s picture

@aspilicious also reproduced the same issue independently.

gábor hojtsy’s picture

Title: Uncaught PHPStan\Broker\ClassAutoloadingException with Redirect 8.x-1.3 » Fail more gracefully when exceptions happen, eg. Uncaught PHPStan\Broker\ClassAutoloadingException with Redirect 8.x-1.3

All right. So there is a problem with Redirect module here. That was fixed on June 22 and released in v1.4, so that should run fine. See https://git.drupalcode.org/project/redirect/commit/a4d287869a4f782fe9019... for the commit that fixed it in redirect.

That said, Upgrade Status should fail more gracefully and not whitescreen.

I tried to reproduce this also with drupal-check, but it uses such a recent (dev) phpstan now that it had a PHP issue within phpstan, haha. This one: Fatal error:

Class PHPStan\Type\MixedType contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (PHPStan\Type\Type::inferTemplateTypes, PHPStan\Type\Type::traverse) in ....drupal/vendor/phpstan/phpstan/src/Type/MixedType.php on line 18

That said, that is totally unrelated to this issue. I submitted a pull request to drupal-check to fix THAT on their side: https://github.com/mglaman/drupal-check/issues/93

I will look into reproducing this issue with Upgrade Status and Redirect 1.3 now and see if we can do something about catching the errors.

gábor hojtsy’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new2.79 KB

This exception is coming from Command\AnalyseApplication->analyse( ).../DeprecationAnalyser.php:345 as per the above stack trace and also my reproducing. This indeed we are not catching. I thought this should do it, but it does not seem to actually catch it. Anyone spots where am I mislead?

(I also removed a lower level try/catch, so we can collect all the exceptions at one place and store more info about them, but that is not where this exception originates from, so it should not change the behaviour either way).

Also needs tests once it works.

gábor hojtsy’s picture

As per the call stack, the try/catch block is not even in this call path for some reason. I guess when PHPStan Broker does spl_autoload_register() that closure is called out of band from our call path, so we cannot catch that exception in a call path based catcher.

So I also tried to set a global exception handler, but no luck there either. Drupal already sets the _drupal_exception_handler() but I tried to set_exception_handler(null); to reset that and also set_exception_handler('Drupal\upgrade_status\DeprecationAnalyser::exceptionHandler'); (after I added the static method) but neither helped.

¯\_(ツ)_/¯

gábor hojtsy’s picture

Issue summary: View changes

Added steps to reproduce.

alexpott’s picture

Well this is broken code no - it seems this has been fixed by #3048310: Fatal error analysing code with phpstan. Symfony\Component\Validator\ExecutionContextInterface never existed so there's not much we can do right? Do we need to tell users to be on the latest version of the contrib module? That would fix this.

The problem is that \Drupal\redirect\Plugin\Validation\Constraint\SourceLinkTypeConstraint::initialize() breaks the interface it implements. So whilst doing the autoload we go straight into the shutdown functions. There's no error to catch. If we want to prevent this type error I think we need to do AST parsing and validate the PHP prior to including it.

alexpott’s picture

try {
  include 'modules/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php';
}
catch (\Throwable $e) {
  var_dump("here");
}

If I run the above script in Drush the error you get is

PHP Fatal error:  Declaration of Drupal\redirect\Plugin\Validation\Constraint\SourceLinkTypeConstraint::initialize(Symfony\Component\Validator\ExecutionContextInterface $context) must be compatible with Symfony\Component\Validator\ConstraintValidatorInterface::initialize(Symfony\Component\Validator\Context\ExecutionContextInterface $context) in modules/redirect/src/Plugin/Validation/Constraint/SourceLinkTypeConstraint.php on line 24
gábor hojtsy’s picture

Yes redirect did fix their error in 1.4, but according to @mixologic, around 900 contrib modules have some kind of PHP parse error when analysed with phpstan. There was a similar one in ctools we found when testing Upgrade Status. If these high profile modules have them, we better try and catch them if we can and not just say "yeah its broken modules". So I was trying to do that :)

I don't know what happens once we catch the exception from phpstan, but that is our primary symptom here. In this case the autoloading fail will halt the processing, so the interface mismatch will not be reached AFAIS. So it could still be useful to catch these cases. @chx proposed this fix to phpstan to make it catchable: https://github.com/phpstan/phpstan/compare/master...chx:chx?expand=1 I will try this locally and see if that helps catch this and gracefully recover for this issue. If the autoloading would have worked but there would still be a type mismatch, that is something we cannot catch apparently, thanks for looking at that @alexpott.

gábor hojtsy’s picture

Sidenote: two types of PHP fatal errors @mixologic found that would fall under the same "cannot catch" umbrella that @alexpott uncovered:

PHP Fatal error:  Declaration of Drupal\date_recur_ss\Plugin\DateRecurInterpreter\SsInterpreter::interpret(array $rules, $language): string must be compatible with Drupal\date_recur\Plugin\DateRecurInterpreterPluginInterface::interpret(array $rules, string $language): string in /var/lib/drupalci/workspace/drupal-checkouts/drupal27/modules/contrib/date_recur_ss/src/Plugin/DateRecurInterpreter/SsInterpreter.php on line 23
PHP Fatal error:  Declaration of Drupal\paragraphs_enhancements\Plugin\Field\FieldWidget\ParagraphsEnhancementsWidget::create($pluginId, $pluginDefinition, array $configuration, Symfony\Component\DependencyInjection\ContainerInterface $container) must be compatible with Drupal\Core\Plugin\ContainerFactoryPluginInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) in /var/lib/drupalci/workspace/drupal-checkouts/drupal2/modules/contrib/paragraphs_enhancements/src/Plugin/Field/FieldWidget/ParagraphsEnhancementsWidget.php on line 22

(These were results of running drupal-check on contrib modules).

alexpott’s picture

StatusFileSize
new5.52 KB

Here's an idea for how to fail a bit more gracefully. We can do another request in the batch to do the scan. This way if it breaks in a way that causes PHP fatal error we can do something a bit nicer for the user because the fail has not happened in the user's request.

The code is a bit janky at the moment but it can be cleaned up.

Status: Needs review » Needs work

The last submitted patch, 13: 3065760-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new218.77 KB
new6.66 KB

Thanks @alexpott, that made me think of even more options :) @chx noting that the execution will continue made me think that we can use the existing shutdown function to gracefully recover. In the prior UI implementation we did have a similar recovery method where we stored which extension failed in state and then cleaned up later. That did not have test coverage (oops) so got refactored out of the module (oops) when it was simplified.

The culprit is the batch JS which bails out when there was a non-JSON response. But we can make Drupal not emit the error and log it instead and also return a sensible JSON response that keeps the batch running. The only problem then is the batch item is not marked complete, so it will kept being invoked again and again and again. So I opted to store a "unique" scanid identified (based on time and random generated at form submit time for this batch). So when we get to a batch item and we find there were already results, we can check if said results were from this same batch and if so, we can ignore trying to do the futile task of parsing again.

This way we can store more useful fatal error details like file name, line number, etc. which @alexpott's solution did not provide. It is true that there is no sandboxing of the parsing in a different HTTP request here, but phpstan itself is quite heavy already so not wrapping it in one more layer of HTTP request may help not run so slow.

Now this definitely needs test coverage to ensure we don't regress the functionality again.

The progress bar BTW tells the user there was a fatal error and we recovered from it triumphantly :D

gábor hojtsy’s picture

StatusFileSize
new921 bytes
new7.56 KB

Hm, it does not exactly work in a no-JS environment where the response is not AJAX and therefore there is already some response. As this sample proves. We can still look at output buffering and emptying the buffer in the error case without outputing it, but generating JSON then is useless to carry on processing. Duh. So probably @alexpott's approach is the workable one.

gábor hojtsy’s picture

Hum, I don't even know how to test this on d.o as there is multiple instances of the fatal PHP file failing on testbot before it ever has a chance to run the tests. It does not seem like sacrificing some verification steps would avoid that as it fails right in composer.

gábor hojtsy’s picture

Status: Needs review » Needs work
waverate’s picture

Related issues: +#3067356: Fail gracefully for HTTP result 500
StatusFileSize
new6.69 KB
new447 bytes
new6.69 KB

From discussion at #3067356: Fail gracefully for HTTP result 500, patch attached to catch HTTP result code 500 .

waverate’s picture

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new8.29 KB
new6.78 KB

Instead of working forward from my patch, I decided to work forward from @alexpott's from #13. Cleaned that up and can now log exceptions in the HTTP request part as well. Let's see how tests will behave here. Fixed the analyse stuff to work with profiles and fixed docs.

Status: Needs review » Needs work

The last submitted patch, 21: 3065760-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Version: 8.x-1.0-alpha5 » 8.x-1.0-beta1
gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new6.78 KB

Cannot reproduce fails locally. Not sure the above was running with beta1.

Status: Needs review » Needs work

The last submitted patch, 24: 3065760-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new6.78 KB

There are even more changes since beta1 in error/warning logic. Retest on dev.

Status: Needs review » Needs work

The last submitted patch, 26: 3065760-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new9.42 KB
new3.16 KB

Putting back the fresh service retrieval because it does matter now given the separate HTTP request, good point @alexpott. Also removing the injected service, since that does not get used anymore. Also fixing the error classification as warning, since that is how it will end up being displayed (with a note to check manually).

Status: Needs review » Needs work

The last submitted patch, 28: 3065760-28.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.21 KB
new4.79 KB

Still cannot figure out why the PHP fatal testing works differently locally and on the testbot. Locally passes. So let's try without that for this issue.

Status: Needs review » Needs work

The last submitted patch, 30: 3065760-30.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Ok this now shows that the actual problem is this:

1) Drupal\Tests\upgrade_status\Functional\UpgradeStatusAnalyseTest::testAnalyser
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Call to deprecated function menu_cache_clear_all(). Deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use\n
-\Drupal::cache('menu')->invalidateAll() instead.'
+'Client error: `POST http://php-apache-jenkins-drupal8-contrib-patches-3352/subdirectory/admin/reports/upgrade/analyze/module/upgrade_status_test_error` resulted in a `403 Forbidden` response:\n
+\n
+\n
+  \n
+    \n
+

This did not show up in previous reports due to the PHP fatal testing masking it. So ehm. I don't know why testbot would not work the same way for doing HTTP requests. We are passing over the cookie after all to the same domain. The http://php-apache-jenkins-drupal8-contrib-patches-3352 domain is the same as in the results HTML files, so it is the right domain for this testbot job.

¯\_(ツ)_/¯

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.27 KB
new1.29 KB

I asked for advice in drupal.org/slack's #testing channel. @mixologic suggested I try on my local testbot. Which I did. And it did fail the same way. Let's try with making the session info debug appear in our fail then. When I fiddled with these details, my local failed as well, so it is down to the session cookie not being passed over properly for some reason on testbots.

Also minor path typofix but that does not make it or break it.

Status: Needs review » Needs work

The last submitted patch, 33: 3065760-33.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Ok so this is strange. Based on the debug code I put in:

json_encode($cookie_jar->toArray())

produces [], so this snippet produces an empty array:

    $session_config = \Drupal::service('session_configuration');
    $request = \Drupal::request();
    $session_options = $session_config->getOptions($request);
    $cookie_jar = new CookieJar();
    $cookie = new SetCookie([
      'Name' => $session_options['name'],
      'Value' => $request->cookies->get($session_options['name']),
      'Domain' => $session_options['cookie_domain'],
      'Secure' => $session_options['cookie_secure'],
    ]);
    $cookie_jar->setCookie($cookie);
gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.26 KB
new828 bytes

Let's check session options.

Status: Needs review » Needs work

The last submitted patch, 36: 3065760-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.29 KB
new854 bytes

So that $session_options comes down to this on testbot (in json):

{"gc_probability":1,"gc_divisor":100,"gc_maxlifetime":200000,"cookie_lifetime":2000000,"cookie_domain":"","cookie_secure":false,"name":"SESSb3e03831c0a5fae43a08856e1e929898"}

This other than having an empty cookie domain matches the rough values locally. Let's check the actual cookie value.

Status: Needs review » Needs work

The last submitted patch, 38: 3065760-38.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Ok that got us "etsrx0yynahPYLbtfU7aLS5QU1AwL21h60gyy4b0dAA" so I blame it on the lack of cookie domain being set on testbot. Based on #38. See https://github.com/guzzle/guzzle/blob/master/src/Cookie/CookieJar.php#L166 for how CookieJar skips cookies with empty domains.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.71 KB
new1.89 KB

Let's try a cookie setting workaround.

gábor hojtsy’s picture

StatusFileSize
new9.92 KB

With testbot worked around, we can restore the basic PHP fatal testing that was not actually causing the fail at all.

gábor hojtsy’s picture

StatusFileSize
new9.87 KB
new779 bytes

Finally remove our debug code.

gábor hojtsy’s picture

Adjusting credits. #drumroll

  • Gábor Hojtsy committed cceea0a on 8.x-1.x
    Issue #3065760 by Gábor Hojtsy, waverate, alexpott, nrackleff,...
gábor hojtsy’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks all! I added #3073644: Add test coverage for uncatchable PHP fatal error testing for adding test coverage as it proved to be challenging in #16 as well. The existing test coverage does prove that there is no regression whatsoever. It does not prove that we improved. I think its fine adding that test coverage in #3073644: Add test coverage for uncatchable PHP fatal error testing and unleash the feature on people already as this was a recurring pain for some testers and is quite a jarring experience without a fix.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.