Skip to content

Replace deprecated IConfig methods with IAppConfig and IUserConfig #6855

@vitormattos

Description

@vitormattos

📋 Description

LibreSign is using deprecated methods from \OCP\IConfig that were deprecated in Nextcloud 33.0.0. The deprecation warning says:

@deprecated 33.0.0 - use {@see IUserConfig} or {@see IAppConfig} directly

These need to be updated to use the new interfaces.

📍 Files that need to be updated

1. lib/Service/AccountService.php

  • Line 163: $this->config->getAppValue('core', 'newUser.sendEmail', 'yes')
    • Use IAppConfig::getValueString() instead
  • Lines 265, 273, 287, 301, 315: Multiple $this->config->getUserValue() calls
    • Use IUserConfig::getUserValue() instead

2. lib/Controller/AccountController.php

  • Line 422: $this->config->setUserValue($user->getUID(), Application::APP_ID, $key, $value)
    • Use IUserConfig::setUserValue() instead

3. lib/Migration/Version12000Date20250517134200.php

  • Line 34: $this->config->getAppValue(Application::APP_ID, 'notify_unsigned_user')
    • Use IAppConfig::getValueString() instead

Note: lib/Service/FolderService.php already uses IAppConfig correctly ✅

✅ What needs to be done

  1. Add proper dependency injection:

    • Inject IAppConfig for app-level configuration
    • Inject IUserConfig for user-level configuration
    • Keep IConfig only if needed for system-level config
  2. Update each file:

    • Add use OCP\Config\IAppConfig; and/or use OCP\Config\IUserConfig;
    • Add the dependencies to the constructor
    • Replace deprecated method calls with the new interfaces
  3. Update tests to mock the new interfaces

  4. Run tests for each changed service:

    composer test:unit -- --filter AccountService
    composer test:unit -- --filter AccountController

📚 Resources

🎯 Important notes

  • Target branch: main
  • Backport: After merging to main, this should be backported to stable branches >= 33
  • Commits: Use Conventional Commits and sign-off (git commit -s)
  • Tests: Always run with --filter flag (see copilot-instructions.md)

💬 Questions?

Feel free to ask in this issue. Don't forget to ⭐️ star this repository!


This task is suitable for first-time contributors! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersphpPull requests that update Php code

    Type

    No type

    Projects

    Status

    4. to release

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions