WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#10319 closed defect (bug) (fixed)

WordPress import fails to create new users

Reported by: yoavf Owned by: yoavf
Milestone: 3.1 Priority: normal
Severity: normal Version: 2.8
Component: Import Keywords: has-patch early
Focuses: Cc:

Description

When an xml import file contain user names with characters other than [a-z][A-Z], importer still asks if you'd like to import the author.

Problem: Usernames cannot have these characters in them.
The author is not imported, and all posts are mapped to the default user (admin ?)

Possible solutions

  1. Do not display the "Import Author" line for those usernames
  1. Display error/warning that the user wasn't imported and that posts were mapped to user "XXX"

Attachments (1)

wp30-import-users.diff (759 bytes) - added by yoavf 4 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 2.9

Or 3., we sanitize the username accordingly.

comment:2 janeforshort4 years ago

  • Milestone changed from 2.9 to Future Release

Punting due to lack of patch.

comment:3 westi4 years ago

Saw this investigating #11484.

Nub of the issue is that export files contain display name which is not user_login safe and sanitize_user can strip it down to an empty username.

comment:4 westi4 years ago

#11548 - Will remove the ability to create duff users but not yet fix the importer.

comment:5 westi4 years ago

(In [12469]) Fix some notices in the importer when importing files from old WordPress versions or not fetching attachments. See #11484.
Ensure that we check that a user is created for the username we specify and otherwise fallback to the current user
See #10319.

comment:6 westi4 years ago

  • Cc westi added
  • Keywords needs-patch added
  • Milestone changed from Future Release to 3.0

That improves this a bit.

Would be great to improve the UX some more in 3.0 to detect the invalid username earlier and offer a better solution that then current fallback.

comment:7 follow-up: hakre4 years ago

What is an invalid / a valid username? We could create a validation function then and deal accordingly with valid / invalid usernames as needed.

comment:8 in reply to: ↑ 7 westi4 years ago

Replying to hakre:

What is an invalid / a valid username? We could create a validation function then and deal accordingly with valid / invalid usernames as needed.

It gets passed through sanitize_user($user_login, true) so the valid name has to match all the rules there.

The big problem at the moment is what to do when the username has no valid chars in it.

I suspect we should modify the first step to show the usernames which will be created and allow the user to change them if no good.

Something like:

Username in import - Username when imported - Use existing user
דיסוננס קוגניטיבי - imported_user_1 (o) [admin\/]

comment:9 hakre4 years ago

sanitize_user($user_login, true)

does not support utf8, allowed chars for a wordpress username are:

WPUSERNAME ::= [a-zA-Z0-9 _.@-]+ while duplicate spaces are not allowed

comment:11 hakre4 years ago

user names als here: #11753

comment:12 yoavf4 years ago

  • Owner set to yoavf
  • Status changed from new to assigned

yoavf4 years ago

comment:13 yoavf4 years ago

  • Keywords has-patch added; needs-patch removed

Why not leave the username field empty for those users?
If the users leave that empty, posts will automatically assigned to the first user.
wp30-import-users.diff does that

comment:14 nacin4 years ago

  • Keywords removed

We should still esc_attr it I think. Looks fine to me though. Might be a little late in the development cycle? I suppose all that would be hurt is that more posts would be mapped to users, instead of to the admin.

comment:15 nacin4 years ago

  • Keywords early added
  • Milestone changed from 3.0 to 3.1

comment:16 nacin3 years ago

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

(In [15961]) Importer and exporter overhaul, mega props duck.

Exporter overhaul:

  • Add author information to export
  • Greater usage of slug identifiers
  • Don't export auto-drafts, spam comments, or edit lock/last meta keys
  • Inline documentation improvements
  • Remove filtering for now (@todo)
  • Bump WXR version to 1.1, but remain back compat in the importer

Importer overhaul (http://plugins.trac.wordpress.org/changeset/304249):

  • Use an XML parser where available (SimpleXML, XML Parser)
  • Proper import support for navigation menus
  • Many bug fixes, specifically improvements to category and custom taxonomy handling
  • Better author/user mapping

Fixes #5447 #5460 #7400 #7973 #8471 #9237 #10319 #11118 #11144 #11354 #11574 #12685 #13364 #13394 #13453 #13454 #13627 #14306 #14442 #14524 #14750 #15055 #15091 #15108.

See #15197.

comment:17 nacin3 years ago

  • Milestone changed from Awaiting Triage to 3.1
Note: See TracTickets for help on using tickets.