Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Postal Code Formula validation #3943

Closed
stanislavprokopov opened this issue Mar 16, 2025 · 3 comments · Fixed by #3949
Closed

[5.x]: Postal Code Formula validation #3943

stanislavprokopov opened this issue Mar 16, 2025 · 3 comments · Fixed by #3949

Comments

@stanislavprokopov
Copy link

What happened?

Description

Postal Code Formula is not validated on save, causing SyntaxError in dev and Internal server error in prod when opening any order in admin panel.

Steps to reproduce

  1. Create a shipping zone and add an Postal Code Formula to Address Condition, enter smth like this postalCode >= '00100' and postalCode <= '03149'), notice the missing opening bracket, save it
  2. Now go to Commerce -> Orders and open any order
  3. You will get an Unexpected ")" in "Postal code formula matching address exception

Expected behavior

Validate formula on save, preventing incorrect value to be saved

Actual behavior

In production you get a Internal server error in dev you get an exception

Craft CMS version

5.6.11

Craft Commerce version

5.3.5

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Copy link

linear bot commented Mar 16, 2025

@lukeholder
Copy link
Member

@stanislavprokopov thanks for reporting this. Unfortunately the condition builder does not have a way to validate the condition syntax, but I have gone ahead and ensured that no PHP error is raised when evaluating the bad condition in this PR: #3949

This will mean the condition will return false if it has any syntax errors, and will silently log the error with the bad formula.

I will update this ticket once the PR is included in the next release. Thanks!

@nfourtythree
Copy link
Contributor

Commerce 5.3.6 has been released with this fix included.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants