Skip to content

fix: preserve zero values in number fields - #2988

Open
RabbiIslamRony wants to merge 1 commit into
sovware:developmentfrom
RabbiIslamRony:fix/custom-number-zero-value
Open

fix: preserve zero values in number fields#2988
RabbiIslamRony wants to merge 1 commit into
sovware:developmentfrom
RabbiIslamRony:fix/custom-number-zero-value

Conversation

@RabbiIslamRony

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

Issue

A custom Number field value of 0 was treated as empty in multiple submission paths, so the metadata was removed instead of saved. The search request also used PHP's default array_filter(), which removed the string value "0"; as a result, an exact search for zero ran without the intended number-field meta query.

Fix

  • Distinguish a genuinely blank Number field from an explicit numeric zero before sanitizing.
  • Preserve numeric zero in the current submission controller, legacy submission path, and admin/metabox metadata filtering.
  • Preserve "0" in custom-field search requests and repopulate it in the search UI.
  • Keep the existing behavior for blank optional fields, exact nonzero number searches, text partial matching, and number ranges.

Test cases

  1. Submit a new listing with the custom Number field set to 0; confirm the metadata exists and is stored as zero.
  2. Edit the value from 0 to 2.50, then back to 0; confirm each value is preserved.
  3. Clear the optional Number field; confirm its metadata is deleted rather than converted to zero.
  4. Submit a new listing with the optional Number field blank; confirm no zero metadata is created.
  5. Search the Number field for 0; confirm only the zero-valued listing is returned and the query value is retained.
  6. Search the Number field for 2; confirm the listing with 3 is not returned.
  7. Search the Number field with the 2-3 range; confirm both boundary values are returned.
  8. Verify the exact-zero and range result layouts on desktop and mobile and confirm no horizontal overflow or visible listing-card regression.

Any linked issues

Checklist

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant