pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

REST API Write access - Fix invalid default value #7339

Closed JoryHogeveen closed 1 month ago

JoryHogeveen commented 1 month ago

Description

De default value for the write_all option of a Pod was set to the Pod name. This results in incorrect parsing of a boolean in PodsRESTFields::field_allowed_to_extend() in write mode.

@sc0ttkclark See testing instructions. I'm not sure how you would like to implement something that will repair old Pods. You could check for ! empty() instead of using filter_var() but that might not be desirable.

Related GitHub issue(s)

Fixes #7327

Testing instructions

  1. Create a Pod without this patch and enable write mode.
  2. Go to PodsRESTFields::field_allowed_to_extend() and dump $all_fields_can_use_mode. It will return false, allways.
  3. Verify with $pod->get_arg( $pod_mode_arg, 'value_not_set' ) and see it returns the Pod name instead of a 1 or 0.
  4. Apply this patch
  5. Disable REST write access and save Pod (important, otherwise it won't reset the value)
  6. Re-enable REST Write access and save Pod.
  7. Redo 1, 2 and 3 and you'll see it returns the correct values now.

PR checklist

what-the-diff[bot] commented 1 month ago

PR Summary

sc0ttkclark commented 1 month ago

Added backcompat handling but did not include a DB migration.