Skip to content

Conversation

@Steph501
Copy link
Contributor

@Steph501 Steph501 commented Dec 7, 2025

Summary

  • Add isDescendant() method to Categorie class to check if a category is a descendant of the current one
  • Add validation in create() and update() methods to prevent setting a descendant as parent
  • Add translation keys for error message (EN/FR)

Fixes #36312

Test plan

  • Normal category creation/update works without errors
  • API call trying to set a descendant as parent returns error 500 with message "ErrorCategoryParentIsDescendant"
  • Interface already filters the selector, this fix adds server-side protection for API and imports

…gnment

Add isDescendant() method to check if a category is a descendant of the current one.
Validate in create() and update() that fk_parent is not a descendant to prevent circular references.
@Steph501
Copy link
Contributor Author

Steph501 commented Dec 7, 2025

The PHPStan failure is not related to this PR.

The errors are:

  • Property CommonObject::$shipping_method_id (int) in isset() is not nullable.
  • Property Propal::$availability_id (int) in isset() is not nullable.

These are pre-existing issues in CommonObject and Propal classes, not in the category code modified by this PR.

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.

2 participants