It happens when using external libraries that at some point, run the error handler manually (in my case it happens with Symfony, but it could happen with any library playing a bit with error handlers).

A very simple solution is make the 5th argument optional providing a default value.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pounard created an issue. See original summary.

pounard’s picture

joseph.olstad’s picture

probably should use the 5.3 syntax for array instead of [] that breaks on 5.3

joseph.olstad’s picture

with that said, 5.3 support should probably be removed completely from 7.x core. php 7 is what my servers are using

joseph.olstad’s picture

so ya, probably ignore my comment #3

Status: Needs review » Needs work

The last submitted patch, 2: 2947291-1-_drupal_error_handler-5th_argument.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

pounard’s picture

Test failures don't seem to be related, I requeued for testing to be sure.

pounard’s picture

In fact, Drupal error handler does not respect the PHP error handler signature, all 3 last parameters must be optional: https://secure.php.net/manual/en/function.set-error-handler.php

pounard’s picture

Status: Needs work » Needs review
FileSize
1.47 KB

Here is an appropriate patch that respects Drupal coding conventions and should pass all tests (I hope).

markus_petrux’s picture

This is also happening un Drupal 8.6 with PHP 7.1, symfony/http-foundation v3.4.17

ArgumentCountError: Too few arguments to function _drupal_error_handler(), 4 passed in web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 240 and exactly 5 expected in web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 240 #0 web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(240): _drupal_error_handler(2, 'session_write_c...', '/var/www/sites/...', 244)
#1 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->Symfony\Component\HttpFoundation\Session\Storage\{closure}(2, 'session_write_c...', '/var/www/sites/...', 244, Array)
#2 web/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(244): session_write_close()
#3 web/core/lib/Drupal/Core/Session/SessionManager.php(198): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->save()
#4 web/vendor/symfony/http-foundation/Session/Session.php(196): Drupal\Core\Session\SessionManager->save()
#5 web/core/lib/Drupal/Core/StackMiddleware/Session.php(60): Symfony\Component\HttpFoundation\Session\Session->save()
#6 web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#7 web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 web/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 web/core/lib/Drupal/Core/DrupalKernel.php(665): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#14 {main}

markus_petrux’s picture

Attached patch for Drupal 8.7.x

It just changes the Drupal error handler with optional arguments those that are documented as optional in php manual. Also note the 5th argument is deprecated in 7.2

http://php.net/set_error_handler

interdruper’s picture

Status: Needs review » Reviewed & tested by the community

#9 / #11 work for me. Thanks.

The last submitted patch, 9: 2947291-9-_drupal_error_handler-signature.patch, failed testing. View results

voleger’s picture

pounard’s picture

This patch is trivial, there is no possible side effect, it's a one liner, reasons are well documented, and it fixes real bugs from real life. There is no reason this isn't commited yet. It should have been commited on both Drupal 7 and 8 at least 6 months ago, and it would have been shipped in stable releases already.

catch’s picture

Version: 8.7.x-dev » 8.6.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 4af96a6a7e to 8.7.x and 0bc2447558 to 8.6.x. Thanks!

  • catch committed 4af96a6 on 8.7.x
    Issue #2947291 by pounard, markus_petrux: Missing argument 5 for...

  • catch committed 0bc2447 on 8.6.x
    Issue #2947291 by pounard, markus_petrux: Missing argument 5 for...
pounard’s picture

@catch, thank you very much. Now only Drupal 7 is missing :)

catch’s picture

This could use a new issue for Drupal 7, linking back to this one.

benjifisher’s picture

Status: Fixed » Closed (fixed)

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