WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#7541 closed defect (bug) (fixed)

Adding a custom field without a value gives unidentified error.

Reported by: hedgepig Owned by:
Milestone: 2.8 Priority: low
Severity: minor Version: 2.7
Component: Administration Keywords: has-patch tested
Focuses: Cc:

Description

On a fresh install...

If you create post1 and add several custom fields of the format 'name'=>'url' everything works fine.

BUT...

If you create post2 (with a title) and try and add one of the custom fields that we previously already defined, then you get the error 'An unidentified error has occurred.'

If you create post2 without a title and add one of the previously defined fields then it adds it, but the name and value are blank.

Attachments (4)

fields copy.jpg (68.9 KB) - added by mrmist 6 years ago.
Showing error box
blanks.jpg (62.9 KB) - added by mrmist 6 years ago.
Blank boxes
7541.diff (1.4 KB) - added by scohoust 5 years ago.
draft-notice-7541.diff (1.9 KB) - added by cyberhobo 5 years ago.
Replaces incorrect previous version.

Download all attachments as: .zip

Change History (30)

comment:1 mrmist6 years ago

Confirming. Applies to ALL custom fields from what I can tell.

Also in 2.7-bleeding. (8665)

comment:2 azaozz6 years ago

  • Keywords reporter-feedback added; admin bug custom removed

Can't reproduce in trunk [8889]. Fields seem to work properly. Could have been js/ajax error because of cached js files. Can you re-test again?

comment:3 jacobsantos6 years ago

Can't reproduce either.

comment:4 mrmist6 years ago

I can still reproduce this with 8895.

The first time I tried it I had absolutely nothing happen. The second (new post) produced the error. Attached example of error.

mrmist6 years ago

Showing error box

comment:5 mrmist6 years ago

For info this is IE 7 for me.

Also I can produce a slightly different error by doing new post and then attempting to add a custom field from the pull-downs without making any other changes on the new post screen - in this event a series of blank boxes is added. (shown in blanks attachment.)

mrmist6 years ago

Blank boxes

comment:6 mrmist6 years ago

Same thing in Opera, which I guess excludes cached scripts, too.

comment:7 azaozz6 years ago

Re-tested in FF, Safari, Opera and IE, all seems to work well. Are there any js errors in Opera? Do the rest of the AJAX functions work well? Any over-jealous firewall/antivirus installed?

comment:8 mrmist6 years ago

No to firewalls/AV. (Actually no AV installed here just now ..)

Not sure what the best way to test other functionality is. Pretty much everything seems to work apart from these custom fields.

No (javascript) errors appear in Opera / IE, you just get the red box.

I don't run a lot of plugins on the svn test but I disabled them all for good measure, still get the same results. It's an odd one.

Incidentally I don't use custom fields. But this would be a pain if I did. I can reproduce the same behaviour on my prod site, which is a different server, apache, and PHP version.

In all events, manually adding a custom field by writing in the name - value pair always works, only the pull-down doesn't.

What is the correct behaviour? When you select from the pull-down is the name value pair supposed to be auto-completed or is it meant to be left blank? 'cos on these they remain blank.

comment:9 jacobsantos6 years ago

  • Priority changed from highest omg bbq to high

For the dropdown, the value should be filled in and the name should be blank. When not using the dropdown, the name should be filled and the value should not be blank.

comment:10 jacobsantos6 years ago

I was able to reproduce.

  1. Create new post.
  2. Enter title.
  3. Save Draft -> (if you don't save draft the custom field won't show up until you save the draft, might be regression or bug).
  4. Enter dropdown for custom field or enter name.
  5. Click "Add Custom Field"

The error "An unidentified error has occurred." will show up below the boxes. This should probably say, "Please enter value for the custom field before adding."

This is probably invalided in the current wording, but a patch should be made to improve the experience.

comment:11 azaozz6 years ago

  • Keywords needs-patch added; reporter-feedback removed
  • Priority changed from high to normal
  • Severity changed from major to normal

Actually the whole postbox is quite unintuitive. The select should only be available at first and have an option "-Type Name-" or similar. When selected it should let you type the field's name.

The Add Custom Field button should be disabled until both name and value are not empty.

comment:12 jacobsantos6 years ago

  • Milestone changed from 2.7 to 2.8
  • Owner changed from anonymous to jacobsantos

Pushing to 2.8, doesn't appear anyone is willing to do this for 2.7.

comment:13 jacobsantos6 years ago

  • Priority changed from normal to low
  • Severity changed from normal to minor

comment:14 jacobsantos5 years ago

  • Owner jacobsantos deleted

comment:15 vladimir_kolesnikov5 years ago

  • Keywords reporter-feedback added

Can't reproduce this in WP 2.7. Does this bug still persist for you?

comment:16 mrmist5 years ago

Yes, it persists in 2.7 and through to 2.8-bleeding 10191.

However, it now only appears for me when attempting to add existing custom fields using the dropdown. It will happily create a new one via the text box.

comment:17 mrmist5 years ago

  • Keywords reporter-feedback removed
  • Summary changed from 2.6.1 Bug with custom fields to Adding a custom field without a value gives unidentified error.
  • Version changed from 2.6.1 to 2.7

Finally pinned this one down - it happens when you attempt to add a custom field name without filling in the value box.

A better error would be "You must supply a value". Either that or it should let you add a name without a value - since once a name value pair is present you can edit the value and leave it blank.

comment:18 scohoust5 years ago

  • Cc wp@… added
  • Keywords has-patch added; needs-patch removed

Here is a proposed patch. This removes the ability to have an empty custom field value which was mentioned above as the desired behaviour. Output messages aren't great but it should be an improvement.

scohoust5 years ago

comment:19 mrmist5 years ago

  • Keywords needs-patch added; has-patch removed

7541.diff is ineffective for me. (Against 10943)

Tested with steps -

New post, enter post title and some text.
Click "add new" in custom field area.
Enter new field name
Click "add custom field".

Message response is still "An unidentified error has occurred."

Without javascript, the page just refreshes instead.

comment:20 cyberhobo5 years ago

  • Cc cyberhobo added

I tested scohoust's patch under Vista + XAMPPLite 1.6.8 following the steps suggested by jacobsantos.

With WP_DEBUG enabled, a hole in the isset logic caused a PHP notice (Undefined index: metakeyselect). After saving a draft, I still got the undefined error message.

I'll attach a patch with my fix for these two problems added to the original.

comment:21 cyberhobo5 years ago

  • Keywords has-patch added; needs-patch removed

Sorry, should have replaced has-patch.

comment:22 mrmist5 years ago

  • Keywords tested 2nd-opinion added

draft-notice-7541.diff fixes the issue for me, though I have not applied the http.php part of the patch as I'm not sure of its relevance to this particular ticket.

On that basis, I'll add the tested flag with the caveat that it doesn't apply to http.php patching, which probably belongs on a different ticket. (Notice fixes for 2.8 springs to mind.)

Also I'm not 100% convinced of the wording "Please check that you have selected" suggests that the user is using the select pull-down, which might or might not be the case. Something like "Please ensure you provide both name and value" might be more accurate, though overly wordy.

comment:23 cyberhobo5 years ago

I'll replace the patch without the http.php stuff, my mistake.

I've also proposed "Please provide a custom field value." for the message, since that is the only use case it seems to apply to.

cyberhobo5 years ago

Replaces incorrect previous version.

comment:24 mrmist5 years ago

  • Keywords 2nd-opinion removed

looks good to me then

comment:25 scohoust5 years ago

That works, thanks for sorting it.

comment:26 azaozz5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10957]) Show proper error when adding a custom field without a value, props scohoust, fixes #7541

Note: See TracTickets for help on using tickets.