Make WordPress Core

Opened 11 years ago

Last modified 7 years ago

#36157 new defect (bug)

Permalink UI shown without typing a title

Reported by: atimmer Owned by:
Priority: normal Milestone:
Component: Permalinks Version: 2.5
Severity: normal Keywords: has-patch needs-unit-tests
Cc: Focuses: javascript, administration

Description

When creating a new post and jumping straight to the content to write a post the permalink UI will still be shown.

Steps to reproduce:

  • 'Add New' post in the admin
  • Type content inside the post content field.
  • Wait until an autosave triggers and finishes. This step can also be achieved by putting wp.autosave.server.triggerSave(); inside the console.

Expected behaviour:
The permalink UI isn't shown because no title has been set yet.

Actual behaviour:
The permalink UI is shown with a post ID as the slug.

Attachments (2)

36157.patch (620 bytes ) - added by atimmer 11 years ago.
wp.36157.numeric-permalink.patch (877 bytes ) - added by tha_sun 10 years ago.

Download all attachments as: .zip

Change History (8)

@atimmer
11 years ago

#1 @atimmer
11 years ago

  • Keywords has-patch added

36157.patch fixes this by checking correctly for a length of zero instead of casting the length to a boolean.

#2 @swissspidy
11 years ago

  • Milestone Awaiting ReviewFuture Release
  • Version 4.4.22.5

Looks like this was broken ever since, see [6953].

!! $('#edit-slug-box > *').length could be an alternative, but an explicit length check is definitely more clear.

#3 @tha_sun
10 years ago

  • Focuses administration added

I don't see how changing that condition would fix the root cause, because it only checks whether the permalink UI already exists on the page, so as to determine when it needs to be generated and initialized (once).

Instead, the root cause is the server-side function get_sample_permalink(), which happens to generate a numeric post_name/slug (the post ID) when an empty title is passed to it.

Therefore, I'd propose to re-categorize this issue into the component "Administration" or "Permalinks".

In addition, there's another bug that causes the permalink UI to still be displayed:

Even though get_sample_permalink() already contains an existing early return statement to cancel the operation (in which case no permalink UI should be generated), the calling function get_sample_permalink_html() does not handle that case yet, so the UI still appears (but with a draft preview link).

Attached patch fixes both issues.

#4 follow-up: @tha_sun
10 years ago

  • Component AutosavePermalinks
  • Version 2.54.5.3

Is there anything I can do to move this issue forward?

The patch is used on a couple of our sites in production and it works correctly.

#5 in reply to: ↑ 4 @SergeyBiryukov
10 years ago

  • Version 4.5.32.5

Replying to tha_sun:

Is there anything I can do to move this issue forward?

Unit tests would be helpful, see https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/.

P.S. The Version field indicates the earliest affected version, not the latest one.

#6 @SergeyBiryukov
10 years ago

  • Keywords needs-unit-tests added
Note: See TracTickets for help on using tickets.