Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

meta-box not saving data #248

Closed
venca163 opened this Issue · 9 comments

4 participants

@venca163

Hello,

couple days ago I have forked and cloned Meta-box and saved it to brand new Wordpress installation to /plugin (newest version both, Meta-box & Wordpress - no other plugins installed). But when I tried to run "demo.php" (as described here) and in WP admin clicked on "new post" wordpress gave me "Are you sure you want to do this? try again later" with no option to proceed. After I remove 2nd meta box from demo.php and clicked on "new post" again, wordpress showed me Meta-box inputs, but after I typed another values and saved it no change of default values was stored into database (I double checked it).

I tried to download Meta-box straight from WP administration and that way everything worked perfectly.

Am I doing something wrong or is this some kind of bug?

Thank you for any help

@funkedgeek
@venca163

Thanks for reply. Unfortunately if I turn autosave off, I am not even possible to load "new post" page (wordpress gives me still the same message: "Are you sure you want to do this? try again later").

@tyl3r

I have the same problem, since i upgraded the plugin to latest zip i can't add post/page/custom post type:

bug

I also checked with demo.php metaboxes and the error is the same.

@funkedgeek

Sounds like whatever change rilwis made for the autosave feature is messing up when you create a new post/page. Definitely related to the nonce detection.

@corvannoorloos

Not a solution, but this is the notice you'll get when WP_DEBUG is enabled: #246

@funkedgeek

Yup, definitely related. When rilwis changed the code to allow autosaving, it messed something up when you create a post.

@funkedgeek

This is what I think the problem is: The save_post function checks for the nonce for the fields and is the nonce is none existent or wrong, it fails, giving us the "are you sure" message. The problem is that a new post doesn't have the nonce, so it invariably fails when you try to create a new post

@funkedgeek

Okay, think I found a solution: Basically, the problem is the checker in save_post. All we really need to check is whether a. the nonce field exists and b. the nonce is valid. We don't need to check for AutoSave anymore since we are using autosave in our code and this should also skirt the issue with quick saves because the nonce won't be there.

I'm gonna do some testing to make sure that this is ironclad and works always before I post a solution to the issue

@rilwis rilwis closed this issue from a commit
@rilwis Fix #248, #249, also [link](http://www.deluxeblogtips.com/forums/view…
…topic.php?id=422)

Shorten checks when saving posts:
- revert check for autosave, using constants. The function `wp_is_post_autosave` is not realiable when current post is Draft
- remove check for user permission, as WP already does that
- remove check for inline-save as verifying nonce is enough

Note: nonce now is verified only, no "permission" nag is displayed when it's invalid. We just return in that case. This won't block other code to execute.
6221daa
@rilwis rilwis closed this in 6221daa
@funkedgeek

Nice solution. Didn't know Wordpress already checks for capabilities but it makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.