0

I made a plugin to update my 3000 users. It is kind of a toolbox to manage and update some users fields.

I am calling the controller directly through its url action.
It is working basically but it stops after 20 seconds when updating too many users, and display a white page in browser, no results.

I can see in my plugin log it updated some few lines before stopping.
I checked php and craft logs and cannot see any error information.

public function actionUsersFix() {

    // Delete all the entry caches
    craft()->templateCache->deleteCachesByElementType('User');

    // Now find the entry IDs
    $criteria = craft()->elements->getCriteria('User', array('group' => 'migMembers', 'limit' => null, 'status' => null, 'localeEnabled' => null));
    $criteria->group = 'migMembers';
    $criteria->limit = null;
    $criteria->status = null;
    $criteria->localeEnabled = null;
    $criteria->accent = '2';

    $userIds = $criteria->ids();
    //$totalEntries = count($userIds);

    //
    foreach ($userIds as $userId)
    {
        $user = craft()->users->getUserById($userId);

        $oldAccent = $user->accent;
        $newAccent = '3';

        $user->getContent()->accent = $newAccent;
        $success = craft()->users->saveUser($user);
        MigPlugin::log('User '.$user->email.' - accent = '. $oldAccent .' - modified = '.$newAccent, LogLevel::Warning);
    }

}
1

It was a php.ini config problem, I put some parameters values up and the update succeeded in less than 2 minutes and completed my users batch update.

So you just need to update the values below and reload your web server (ie: Apache).

max_execution_time 120 (instead of initial value 30)  
memory_limit 512M (instead of initial value 128M)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.