Opened 8 years ago
Closed 4 months ago
#44530 closed defect (bug) (worksforme)
Post or page custom fields give wrong error message when enter value only.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Editor | Keywords: | has-screenshots has-patch |
| Focuses: | Cc: |
Description
When I enter custom field's value without field name on the page and click on "Add Custom Field" button, The custom field gives the wrong error message "Please provide a custom field value".
Normally, Message should "Please provide a custom field name." Because I entered only custom field value not a custom field name.
I have attached the screenshot to get the better idea about the issue.
Attachments (3)
Change History (7)
#1
@
8 years ago
- Component changed from Administration to Posts, Post Types
- Focuses administration added; ui accessibility javascript removed
- Milestone changed from Awaiting Review to Future Release
- Severity changed from major to normal
- Version trunk deleted
Regarding 44530.diff:
empty() already does an isset() check, so there's no need for both.
Perhaps it's better to use au isset( $_POST['metakeyinput'] ) && '' === $_POST['metakeyinput'] ) check.
#4
@
4 months ago
- Component changed from Posts, Post Types to Editor
- Focuses administration removed
- Milestone Future Release deleted
- Resolution set to worksforme
- Status changed from new to closed
Reproduction Report
Description
❌ This report can't validate that the issue can be reproduced.
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 140.0.0.0
- OS: Windows 10/11
- Theme: Twenty Sixteen 3.6
- MU Plugins: None activated
- Plugins:
- BBB Testing Dolly
- Classic Editor 1.6.7
- Test Reports 1.2.0
Testing Instrutions
- Using the code provided below.
- ❓ If no key is provided, nothing is stored.
Actual Results
- ❌ Error condition occurs (reproduced).
Additional Notes
- I'm not sure if the resolution #43559 has impacted this, but I cannot reproduce this anymore.
- I've provided a simple example for adding new post meta, for key and value. Please don't hesitate to expand this if I'm missing something.
Supplemental Artifacts
Sample code:
<?php function custom_kv_meta_box() { add_meta_box( 'custom_kv_meta', __('Custom Key-Value', 'textdomain'), 'custom_kv_meta_callback', 'post', 'side', 'default' ); } add_action('add_meta_boxes', 'custom_kv_meta_box'); function custom_kv_meta_callback($post) { wp_nonce_field('custom_kv_meta_nonce', 'custom_kv_meta_nonce'); echo '<label for="custom_kv_key">' . __('Key:', 'textdomain') . '</label><br>'; echo '<input type="text" id="custom_kv_key" name="custom_kv_key" value="" style="width:100%;"><br><br>'; echo '<label for="custom_kv_value">' . __('Value:', 'textdomain') . '</label><br>'; echo '<input type="text" id="custom_kv_value" name="custom_kv_value" value="" style="width:100%;">'; } function custom_kv_save_meta($post_id) { if (!isset($_POST['custom_kv_meta_nonce']) || !wp_verify_nonce($_POST['custom_kv_meta_nonce'], 'custom_kv_meta_nonce')) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!current_user_can('edit_post', $post_id)) { return; } add_post_meta($post_id, $_POST['custom_kv_key'], $_POST['custom_kv_value']); } add_action('save_post', 'custom_kv_save_meta');
Note: See
TracTickets for help on using
tickets.
1st screenshot