#5257 closed defect (bug) (duplicate)
Pages Must Be Saved Before Adding Custom Fields
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.3 |
Component: | Administration | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
If you add a custom field to an unsaved page, publishing the page turns it into a draft post and data is lost.
Environment:
- At 2.3.1-RC1, SVN version 6280 (http://svn.automattic.com/wordpress/branches/2.3)
Repro Steps:
- Create a new page.
- Title it "Custom Field Bug".
- Enter some text into the Page Content area.
- Create a custom field (I used key="file", value="foo bar baz"). Click "Add Custom Field".
- Click Publish.
Expected Result: Page should publish.
Observed Result:
- After you click publish, it navigates to "Manage->Pages" menu but the page is not there.
- Click on "Manage->Posts" and you will see a new, unpublished post (not page) that
- (A) does have the custom field, and
- (B) does not have the Post Content entered in step 3, and
- (C) does not have the title "Custom Field Bug" from step 2 -- instead, the title is "Draft created on (date & time)".
Note: I could not reproduce this for a post. It only happens for pages.
Workaround:
- Create a new page.
- Title it "Custom Field Bug Workaround".
- Click "Save and continue editing".
- Create a custom field (I used key="file", value="foo bar baz"). Click "Add Custom Field".
- Click Publish.
This gives the expected result.
Change History (9)
#1
@
18 years ago
- Milestone 2.3.1 deleted
- Resolution set to duplicate
- Status changed from new to closed
This ticket was mentioned in PR #5261 on WordPress/wordpress-develop by @Bernhard Reiter.
22 months ago
#2
- Keywords has-patch has-unit-tests added
Supplementary material for #5257 :)
Trac ticket: N/A
@Bernhard Reiter commented on PR #5261:
22 months ago
#3
@gziolo I'm hoping that this PR will become the final piece to implement Block Hooks. It should be pretty much feature-complete if I didn't miss anything 🙂
@Bernhard Reiter commented on PR #5261:
22 months ago
#4
Weird, unit tests are currently failing:
Invalid argument supplied for foreach() /var/www/src/wp-includes/blocks.php:754
That's this line: https://github.com/WordPress/wordpress-develop/blob/aa033cba5cd3424a0445c6cd95e34307986880a1/src/wp-includes/blocks.php#L754
I wonder if/why the block_hooks
field isn't available at all (rather than defaulting to the empty array)?
@Bernhard Reiter commented on PR #5261:
22 months ago
#5
Workaround in bd1c57bb20. Let's see if that works.
@Bernhard Reiter commented on PR #5261:
22 months ago
#6
Seeing the same test failure I had earlier:
Invalid argument supplied for foreach() /var/www/src/wp-includes/blocks.php:757
Maybe I need to add an is_array
check alongside property_exists
.
@Bernhard Reiter commented on PR #5261:
22 months ago
#7
Seeing the same test failure I had earlier:
Invalid argument supplied for foreach() /var/www/src/wp-includes/blocks.php:757Maybe I need to add an
is_array
check alongsideproperty_exists
.
@Bernhard Reiter commented on PR #5261:
22 months ago
#8
Thanks a lot for the test coverage @gziolo, I quite like your approach! 😄
@Bernhard Reiter commented on PR #5261:
22 months ago
#9
Committed to Core in https://core.trac.wordpress.org/changeset/56649.
Duplicate of #3700