neos / neos/flow-development-collection

AOP: JointPoint->hasMethodArgument does not recognize NULL

Open
#970 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Good first issue P: Flow T: PHP
Dominant language
PHP
Stars
143
Forks
191
Avg merge
3d 12h
Merged PRs (30d)
9

Description

Description

I created a aspect for tracking model changes (executing on every setter).
To assure that argument is passed, I check the jointPoint for the method-argument.
As the model attribute value has been changed from a value (e.g. object) to null, I would like to track that it changed. But: $joinPoint->isMethodArgument('propertyName') returns false. Although getArguments returns [propertyName => NULL]

The problem is here:
https://github.com/neos/flow-development-collection/blob/a2d086a2a38c369a455f2e7cb2449f7df4f09cb6/Neos.Flow/Classes/Aop/JoinPoint.php#L176

isset does return false, if value is set to NULL. Therfore, array_key_exists should be used:

    public function isMethodArgument($argumentName)
    {
        return array_key_exists($argumentName, $this->methodArguments);
    }

quickwin ;)

Expected behavior

JointPoint with arguments: ['myAttribute' => NULL]
Method isMethodArgument('myAttribute') should return true

Actual behavior

returns false

Affected Versions

Neos: latest (but code exists more than 2 years)
Flow: latest

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Neos.Flow/Classes/Aop/JoinPoint.php at the isMethodArgument method and review how methodArguments is checked for a NULL value. Verify the reported case where getArguments contains myAttribute => NULL, and confirm that isMethodArgument('myAttribute') returns true afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.