Closed hingst closed 5 years ago
@hingst thanks for the PR (and apologies for the delay in getting to reviewing it). This makes sense, however I noticed travis is failing which I want to investigate. Also, it would be helpful to add some unit tests that demonstrate this (eg they should break before your fix, but pass after it)
Added some tests in https://github.com/adamsilverstein/wp-post-meta-revisions/pull/43/commits/7d00f88568708bb2df414e0a590761ce6f8fbd84
Tests pass locally for me after your fix, and fail before. Adjusted travis.yml, the error so far seems build related:
ERROR: Looks like you're using PHPUnit 8.0.4. WordPress is currently only compatible with PHPUnit up to 7.x.
Please use the latest PHPUnit version from the 7.x branch.
@adamsilverstein Need help to get PHPCS running properly ?
Hey @jrfnl - I will always accept an offer of help and yes I would love to get it running on this project, (ideally) in a separate PR.
phpcs isn't running yet on this project - I only "removed" it here because I'm trying to get Travis to run the tests correctly - they fail mostly it seems because phpunit version is too high to use with WordPress on the newer PHP version builds. I added some code from a stack exchange ticket that sets the phpunit version per build to fix that and that code include the phpcs versions which i was later removing here.
Long story short, thanks for your offer of help!
@adamsilverstein I'll be happy to take a look. Should I open a separate issue to discuss the requirements you'd want ?
Excellent , thank you @jrfnl !
Tests are passing, merging this!
This PR fixes a bug that removes backslashes from all meta fields when restoring a revision.
Steps to reproduce the bug:
"some\text"
on any postExpected result: The meta field's value should still be
"some\text"
Actual result: The meta field's value is now"sometext"
This is due to a lack of adding slashes before reinserting the restored field value into the post meta. Wordpress expects meta content to be slashed for some reason. From the Codex: "Post meta values are passed through the stripslashes() function upon being stored, so you will need to be careful when passing in values (such as JSON) that might include \ escaped characters."