Skip to content

Import fails on Call to a member function getUID() on null #1020

@helmo

Description

@helmo

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Export account from standalone Nextcloud 32.0.5
  2. Set up new AOI instance
  3. copy zip file to new data dir
  4. docker exec -t --user www-data nextcloud-aio-nextcloud php occ user:import /mnt/ncdata/testuser_2026-01-23_19-17-16.zip

Expected behaviour

A successful import without error messages.

Actual behaviour

Tell us what happens instead, if possible also add a screenshot

Error: Call to a member function getUID() on null in /var/www/html/custom_apps/user_migration/lib/Command/Import.php:80
Stack trace:
#0 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\UserMigration\Command\Import->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/html/3rdparty/symfony/console/Application.php(1083): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\UserMigration\Command\Import), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/console.php(90): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#6 /var/www/html/occ(33): require_once('/var/www/html/c...')

With this mockup patch the import runs fine and prints both success messages.

diff --git lib/Command/Import.php lib/Command/Import.php
index 28f474c..f987449 100644
--- lib/Command/Import.php
+++ lib/Command/Import.php
@@ -77,7 +77,9 @@ class Import extends Command {
                        $importSource = new ImportSource($path);
                        $this->migrationService->import($importSource, $user, $io);
                        /* Reset exported state of user after import */
-                       $this->config->deleteUserValue($user->getUID(), Application::APP_ID, 'lastExport');
+                       if (!empty($user)) {
+                               $this->config->deleteUserValue($user->getUID(), Application::APP_ID, 'lastExport');
+                       }
                        $io->writeln("Successfully imported from {$path}");
                } catch (\Exception $e) {
                        if ($io->isDebug()) {

I think the problem is that $user is not passed by reference, thus when no --user option is given it remains NULL in this scope.

Successfully imported testuser
Successfully imported from /mnt/ncdata/testuser_2026-01-23_19-17-16.zip

Server configuration

Web server: Apache

Database: PostgreSQL

PHP version: 8.3.29

Nextcloud version: 32.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending approval or rejectionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions