Problem/Motivation

The social_user_export module gives the ability to export all users over all pages on /admin/people. The code for that functionality is in src/ExportUser.php. It uses the uid to determine the next user to export in the batch. However this does not work when the view query is already altered in another hook. For example with the following code:

<?php
/**
 * Implements hook_views_query_alter().
 *
 * Make sure we filter out user 1 from the people overview.
 */
function mymodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  if ($view->id() == 'user_admin_people') {
    foreach ($query->where as &$condition_group) {
      foreach ($condition_group['conditions'] as &$condition) {
        // Make sure we filter out AN users and User 1 for SaaS customers on
        // the admin/people overview.
        if ($condition['field'] == 'users_field_data.uid') {
          $condition = array(
            'field' => 'users_field_data.uid',
            'value' => '1',
            'operator' => '>',
          );
        }
      }
    }
  }
}
?>

Then you will end up with a .csv file with the same user exported multiple times.

Proposed resolution

If we use the offset method instead this is much more robust and should not have any downside. This means we can also remove a few lines of code used to set and retrieve the current_id in the $context array.

    $view->setOffset($context['sandbox']['progress']);

Comments

jaapjan created an issue. See original summary.

jaapjan’s picture

Assigned: jaapjan » Unassigned
Status: Active » Needs review

  • 11fe11b committed on 8.x-1.x
    Merge pull request #774 from goalgorilla/feature/2950391
    
    Issue #2950391...
  • jaapjan committed 1d2931e on 8.x-1.x
    Issue #2950391 by jaapjan: user export should use offset method instead...
jaapjan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.