Hello,

I ran cron on my site and got this warning.

Missing argument 4 for faq_node_access() faq.module:32

I don't know if this is a bug or not or if it's serious. The warning came up 22 times in my terminal.

Many thanks.

M

Comments

lilbebel created an issue. See original summary.

livido’s picture

on line #32 , you must change it to:

function faq_node_access(\Drupal\node\NodeInterface $node, $op, $account) {

sumitmadan’s picture

Status: Active » Postponed (maintainer needs more info)

Hi lilbebel,

I am not able to reproduce the error. Would you please provide me the steps to reproduce it?

Please make sure you are using the latest code of 8.x-1.x version.

lilbebel’s picture

@sumitmadan

Thank you for following up and sorry for my slow reply. I ended up having to do some major reworking of the site including moving it to a different database so now it isn't throwing the error anymore. I was working on SQLite locally and had to move it to MySQL so perhaps that was the issue. At this point though, I don't have access to the original issue. Sorry for the inconvenience.

M

jurgenhaas’s picture

Status: Postponed (maintainer needs more info) » Active

I'm seeing this warning too, but only on the development site with the settings such that warnings get displayed, which by default is turned off in Drupal. You get this when you enable the settings.local.php and in particular the following line is making sure you get such output:

$config['system.logging']['error_level'] = 'verbose';

The full output of the error is this:

Warning: Missing argument 4 for faq_node_access() in faq_node_access() (line 32 of modules/contrib/faq/faq.module).
faq_node_access(Object, 'view', Object)
call_user_func_array('faq_node_access', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('node_access', Array) (Line: 85)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 68)
Drupal\node\NodeAccessControlHandler->access(Object, 'view', Object, 1) (Line: 187)
Drupal\node\Entity\Node->access('view', Object, 1) (Line: 48)
Drupal\Core\Entity\EntityAccessCheck->access(Object, Object, Object)
call_user_func_array(Array, Array) (Line: 163)
Drupal\Core\Access\AccessManager->performCheck('access_check.entity', Object) (Line: 139)
Drupal\Core\Access\AccessManager->check(Object, Object, Object, 1) (Line: 112)
Drupal\Core\Access\AccessManager->checkRequest(Object, Object, 1) (Line: 101)
Drupal\Core\Routing\AccessAwareRouter->checkAccess(Object) (Line: 86)
Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 154)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 120)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 206)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 120)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 74)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
jurgenhaas’s picture

Status: Active » Needs review
StatusFileSize
new567 bytes

The comment from @livido above is quite correct and attached is a patch that does that for you. Just verify your function signature with the hook definition and you'll see that you have one argument to many.

Status: Needs review » Needs work

The last submitted patch, 6: missing_argument_4_in_2743715-6.patch, failed testing.

jurgenhaas’s picture

Status: Needs work » Active

Not sure why the test failed, can somebody help please?

Status: Active » Needs work

The last submitted patch, 6: missing_argument_4_in_2743715-6.patch, failed testing.

dom.’s picture

Status: Needs work » Needs review
StatusFileSize
new549 bytes
+++ b/faq.module	(revision )
@@ -29,8 +29,8 @@
+function faq_node_access(\Drupal\node\NodeInterface $node, $op, $account) {

function faq_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) {

Patch #6 works nice.
As per documentation though (https://api.drupal.org/api/drupal/core!modules!node!node.api.php/functio...) I would just enforce the type check on third arguments.

Status: Needs review » Needs work

The last submitted patch, 10: missing_argument_4_on_node_access--2743715-10.patch, failed testing.

BD3’s picture

Patch in #10 removes the warning for me. Not sure why it failed testing again though.

ruslan piskarov’s picture

Status: Needs work » Reviewed & tested by the community

Patch in #10 removes the warning for me.

fsayoub’s picture

Patch #10 removed the warning for me.

gg24’s picture

Hi,

I am able to reproduce the issue and patch works as expected. This can be marked as fixed.

Thanks!

ruslan piskarov’s picture

@gg24, the patch should be applied and committed before. Will wait te reply from @stella.

  • Dom. authored 0d56acf on 8.x-1.x
    Issue #2743715 by jurgenhaas, Dom.: Missing argument 4 for...
sumitmadan’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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