WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#14757 reopened enhancement

users with no posts are not exported

Reported by: sillybean Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0.1
Component: Export Keywords: 2nd-opinion needs-patch
Focuses: Cc:

Description

I just exported a large standalone site and imported into a multisite setup, and I discovered that a number of users who hadn't yet posted anything didn't get moved to the new site.

Attachments (3)

14757.diff (2.0 KB) - added by logiclord 7 years ago.
Users with the ability to edit posts and above can be exported
14757.2.diff (1.8 KB) - added by logiclord 7 years ago.
Blog id added and !=0 used
14757.3.diff (1.9 KB) - added by logiclord 7 years ago.
specific capability test. Still needs testing.

Download all attachments as: .zip

Change History (14)

#1 follow-up: @duck_
7 years ago

  • Keywords 2nd-opinion added

The arguments against would be that you could potentially be creating a massive export file with all the users and that WXR export files are "not intended to serve as a complete backup of your site".

Though I suppose only users with edit_posts capability and above could be exported or something.

#2 in reply to: ↑ 1 @nacin
7 years ago

Replying to duck_:

Though I suppose only users with edit_posts capability and above could be exported or something.

That seems like a good idea.

#3 @nacin
7 years ago

  • Type changed from defect (bug) to enhancement

@logiclord
7 years ago

Users with the ability to edit posts and above can be exported

#4 @logiclord
7 years ago

all changes to be made in wp-admin/includes/export.php .
We can also specify selective users as mentioned in diff file.

#5 @logiclord
7 years ago

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

#6 @logiclord
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#7 @scribu
7 years ago

  • Keywords has-patch added

#8 @nacin
7 years ago

  • Keywords needs-patch added; has-patch removed

This patch isn't scalable and doesn't use the API properly.

Querying all user IDs in a multisite instance might result in thousands (or millions) of users to loop through. That's a lot of queries. What we could do instead is join the usermeta table and fetch users that are specifically assigned to this blog. (And at that point, we'd probably just use get_users() with a blog ID.)

The logic is also flawed -- we can't make assumptions based on roles. We'd instead need to run user_can() for each user -- which is pretty expensive for so many users. Will take too much memory. The goal here would be one of two things: export any user with a user level <> 0, or export any user tied to the blog in general (including subscribers). If our goal is to include users in export files for now on, then this seems reasonable (except where limited by just too many users).

It should be noted that user level <> 0 is a hack -- normally, we can only check capabilities. Not role names, not user levels. Just when using the API for future patches.

#9 @scribu
7 years ago

Re user level <> 0: #16714

@logiclord
7 years ago

Blog id added and !=0 used

@logiclord
7 years ago

specific capability test. Still needs testing.

#10 @netweb
4 years ago

  • Cc stephen@… added
Note: See TracTickets for help on using tickets.