Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
633 stars 197 forks source link

ParameterNotFoundException: Expected parameter(s): email, email #287

Closed LXAfterDark closed 3 years ago

LXAfterDark commented 6 years ago

Laravel Framework version: 5.6 NeoEloquent version: 1.4.6

This is likely something of a duplicate of (closed) issue #272. When attempting to change a password with the built-in Auth functionality of Laravel, the following error is thrown:

ParameterNotFoundException: Expected parameter(s): email, email

The exception is ostensibly being thrown by the function affectingStatement($query, $bindings = array()), which appears between lines 210 and of 223 neoeloquent\src\Connection.php.

All other portions of Laravel Auth appear to work flawlessly. I can register new users and authenticate all day long.

Digging through the stack trace, I think I see what is happening, but I can't really explain why. I noticed the following parameters being passed to affectingStatement():

$query = "MATCH (password_resets:password_resets) WHERE password_resets.email = {email} OPTIONAL MATCH (password_resets:password_resets)-[r]-()  WHERE password_resets.email = {email} DELETE  password_resets,r"

$bindings = [  0 => "email@resetme.com" ]

It would seem as though, when attempting to purge any existing forgotten password tokens associated with the user-supplied e-mail address, NeoEloquent is barfing on the fact that the duplicate {email} token appearing in the Cypher query that has been generated. Pursuing this a bit further, it appears that the code responsible for generating that Cypher query can be found at Illuminate\Auth\Passwords\DatabaseTokenRepository.php, line 98 (inside of function deleteExisting(CanResetPasswordContract $user)):

return $this->getTable()->where('email', $user->getEmailForPasswordReset())->delete();

If I had to speculate (and I'm new enough to both Laravel and NeoEloquent that speculation is all I'm capable of right now), it would seem as though whichever function inside of NeoEloquent is responsible for preparing the Cypher query is annoyed that there are two parameters in the query, but only one element in the $bindings array, and that is what is ultimately leading to the ParameterNotFoundException that is being thrown.

dgerike commented 6 years ago

@TheOneTrueLX, @alex-jf Thanks for digging into it. Had the same issue. Seems to be buggy since Laravel 5.5.

Mulkave commented 6 years ago

A fix is now available in v1.4.7 thanks to @alex-jf 's PR and confirmed to be working by @dgerike.

Please update and confirm so that we close this.

Much appreciated 🙌

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.