studiopress / agentpress-listings

AgentPress Listings
http://wordpress.org/plugins/agentpress-listings/
GNU General Public License v2.0
9 stars 11 forks source link

Property Details fields are not saved when updating listings on WP 5.3.1 #47

Closed madsad87 closed 4 years ago

madsad87 commented 4 years ago

Describe the bug In 1.3.2 and 1.3.3, while on WP Core 5.3.1 content entered into the Property Details input boxes:

Screen Shot 2019-12-14 at 12 11 04 PM

To Reproduce Steps to reproduce the behavior:

  1. Go to a site running WordPress Core version 5.3.1
  2. Edit an existing listing or make a new listing.
  3. Modify any existing value, or add new values.
  4. Save the value

Expected behavior The modified fields will be cleared after saving.

Video Replication https://www.loom.com/share/ea0ce018108942268f06c3ccf11afbb1

Screenshot Screen Shot 2019-12-14 at 11 44 26 AM

Version

Device and browser information

Reported at https://wordpress.org/support/topic/agentpress-listings-plugin-error-when-upgrading-wordpress-5-3-1/

nickcernis commented 4 years ago

Thank you for this helpful report, @madsad87. We'll look into a fix this week.

nickcernis commented 4 years ago

Seems to relate to this ticket in WP core: https://core.trac.wordpress.org/ticket/48955

WP 5.3.1 changes cause potential backwards compatibility breakage with kses

Changing wp_kses to wp_kses_post_deep in includes/class-agentpress-listings.php fixes it:

-$property_details = array_map( 'wp_kses', array( wp_unslash( $_POST['ap'] ) ), array( $this->allowed_tags ) );
+$property_details = array_map( 'wp_kses_post_deep', array( wp_unslash( $_POST['ap'] ) ), array( $this->allowed_tags ) );

But this will need further testing, and we also need to check other usages of wp_kses under WP 5.3.1.

Edit: we can't just switch to wp_kses_post_deep here because we can't pass it the $allowed_html param.

Also noting that the issue appears to be that the field is reverted to the original state (the edit is lost), rather than the field clearing. (i.e. This bug does not appear to destroy original data, only the edit. It has the effect of clearing the field if it had nothing in to begin with, though.)

nickcernis commented 4 years ago

I have a fix in a pull request here: https://github.com/studiopress/agentpress-listings/pull/48

I'll work with our team to schedule testing and release.