#10319 closed defect (bug) (fixed)
WordPress import fails to create new users
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | Import | Version: | 2.8 |
| Severity: | normal | Keywords: | has-patch early |
| Cc: | westi |
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
- Do not display the "Import Author" line for those usernames
- Display error/warning that the user wasn't imported and that posts were mapped to user "XXX"
Attachments (1)
Change History (18)
- Milestone changed from Unassigned to 2.9
comment:2
janeforshort — 3 years ago
- Milestone changed from 2.9 to Future Release
Punting due to lack of patch.
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.
#11548 - Will remove the ability to create duff users but not yet fix the importer.
- 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.
What is an invalid / a valid username? We could create a validation function then and deal accordingly with valid / invalid usernames as needed.
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\/]
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
see also #11777
comment:11
hakre — 3 years ago
user names als here: #11753
comment:12
yoavf — 3 years ago
- Owner set to yoavf
- Status changed from new to assigned
comment:13
yoavf — 3 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
nacin — 3 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
nacin — 3 years ago
- Keywords early added
- Milestone changed from 3.0 to 3.1
comment:16
nacin — 3 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
nacin — 3 years ago
- Milestone changed from Awaiting Triage to 3.1

Or 3., we sanitize the username accordingly.