Skip to content

CommandFactory: reject named arguments as those are not supported#1508

Open
janedbal wants to merge 3 commits into
predis:v2.xfrom
janedbal:named-arguments
Open

CommandFactory: reject named arguments as those are not supported#1508
janedbal wants to merge 3 commits into
predis:v2.xfrom
janedbal:named-arguments

Conversation

@janedbal

@janedbal janedbal commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Since predis 2.3.0, named arguments are not supported (at least in SET command) due to this change as the value argument does not meet the condition there.

Thus, following code broke our production upon upgrade:

$redis->set('foo', value: null);

At first, I was about to fix this by supporting it inside SET::setArguments, but as all the command calls are implemented via __call, I believe it is safer to rely on the fact that your users are not using named arguments at all.

@janedbal janedbal requested a review from tillkruss as a code owner February 11, 2025 16:12

@tillkruss tillkruss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests failing.

@janedbal

janedbal commented Feb 12, 2025

Copy link
Copy Markdown
Contributor Author

Tests failing.

Adjusted. The remaining failures are unrelated.

@tillkruss tillkruss self-assigned this Feb 12, 2025
@tillkruss

tillkruss commented Feb 13, 2025

Copy link
Copy Markdown
Member

This feels a bit overkill, especially since we merged #1509? Mainly because we don't advertise named parameters or include them inside of the stubs.

So I assume someone just came up with value:?

@janedbal

Copy link
Copy Markdown
Contributor Author

This feels a bit overkill, especially since we merged #1509?

@tillkruss Not everybody uses PHPStan, so I think your library should either:

  1. Note BC break in 2.3.0 that named args are no longer supported for SET
  2. Fix the BC break by supporting named args again
  3. Decide to no longer support named args to enable similar changes without a risk of breaking things (this MR)

@tillkruss

Copy link
Copy Markdown
Member
  1. Note BC break in 2.3.0 that named args are no longer supported for SET

I don't see this as a BC issue, was this feature listed anywhere ever or did it just happen to work?

@janedbal

Copy link
Copy Markdown
Contributor Author

was this feature listed anywhere ever or did it just happen to work?

I believe users are expecting native PHP features to work.

I don't see this as a BC issue

If my code was working fine before upgrade, but fails hard on ERR syntax error after upgrade, I'd say it is a BC break. Even when unintentional.

@janedbal

janedbal commented Feb 14, 2025

Copy link
Copy Markdown
Contributor Author

If you dislike this PR, I can send PR fixing the broken support of named args.

@tillkruss

Copy link
Copy Markdown
Member

My point is it's not a breaking change, because it's not an officially supported feature, nor are there tests for it. It just happened to have worked.

If you want to restore named args support, please do.

@tillkruss

Copy link
Copy Markdown
Member

@vladvildanov Any thoughts on this?

@tillkruss tillkruss removed their assignment Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants