Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nextcloud] app isn't compatible with version 28 due to using deprecated methods. #65

Open
MahdiBaghbani opened this issue Mar 7, 2024 · 8 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@MahdiBaghbani
Copy link
Member

This whole section needs to be updated.

$container->registerService('UserService', function ($c) {
return new \OCA\ScienceMesh\Service\UserService(
$c->query('UserSession')
);
});
$container->registerService('UserSession', function ($c) {
return $c->query('ServerContainer')->getUserSession();
});
// currently logged in user, userId can be gotten by calling the
// getUID() method on it
$container->registerService('User', function ($c) {
return $c->query('UserSession')->getUser();
});

currently it leads to:

{
  "reqId": "3VjfetZyHc0vfLfZ2lrx",
  "level": 3,
  "time": "2024-03-07T09:39:26+00:00",
  "remoteAddr": "172.19.0.10",
  "user": "--",
  "app": "index",
  "method": "POST",
  "url": "/index.php/apps/sciencemesh/~einstein/api/auth/Authenticate",
  "message": "Could not resolve userSession! Class \"userSession\" does not exist",
  "userAgent": "Go-http-client/1.1",
  "version": "28.0.2.5",
  "exception": {
    "Exception": "OCP\\AppFramework\\QueryException",
    "Message": "Could not resolve userSession! Class \"userSession\" does not exist",
    "Code": 0,
    "Trace": [
      {
        "function": "OC\\AppFramework\\Utility\\{closure}",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 83,
        "function": "array_map"
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 128,
        "function": "buildClass",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
        "line": 146,
        "function": "resolve",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
        "line": 468,
        "function": "query",
        "class": "OC\\AppFramework\\Utility\\SimpleContainer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
        "line": 440,
        "function": "queryNoFallback",
        "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 163,
        "function": "query",
        "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1069,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/html/index.php",
        "line": 39,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
    "Line": 114,
    "Previous": {
      "Exception": "OC\\AppFramework\\Utility\\QueryNotFoundException",
      "Message": "Could not resolve userSession! Class \"userSession\" does not exist",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 146,
          "function": "resolve",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/ServerContainer.php",
          "line": 173,
          "function": "query",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
          "line": 443,
          "function": "query",
          "class": "OC\\ServerContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 96,
          "function": "query",
          "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
          "type": "->"
        },
        {
          "function": "OC\\AppFramework\\Utility\\{closure}",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 83,
          "function": "array_map"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 128,
          "function": "buildClass",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 146,
          "function": "resolve",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
          "line": 468,
          "function": "query",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
          "line": 440,
          "function": "queryNoFallback",
          "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 96,
          "function": "query",
          "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
          "type": "->"
        },
        {
          "function": "OC\\AppFramework\\Utility\\{closure}",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 83,
          "function": "array_map"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 128,
          "function": "buildClass",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
          "line": 146,
          "function": "resolve",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
          "line": 468,
          "function": "query",
          "class": "OC\\AppFramework\\Utility\\SimpleContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php",
          "line": 440,
          "function": "queryNoFallback",
          "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/App.php",
          "line": 163,
          "function": "query",
          "class": "OC\\AppFramework\\DependencyInjection\\DIContainer",
          "type": "->"
        },
        {
          "file": "/var/www/html/lib/private/Route/Router.php",
          "line": 315,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::"
        },
        {
          "file": "/var/www/html/lib/base.php",
          "line": 1069,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->"
        },
        {
          "file": "/var/www/html/index.php",
          "line": 39,
          "function": "handleRequest",
          "class": "OC",
          "type": "::"
        }
      ],
      "File": "/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php",
      "Line": 135
    },
    "message": "Could not resolve userSession! Class \"userSession\" does not exist",
    "exception": {},
    "CustomMessage": "Could not resolve userSession! Class \"userSession\" does not exist"
  }
}
@MahdiBaghbani MahdiBaghbani added bug Something isn't working critical Show-stopper for production labels Mar 7, 2024
@MahdiBaghbani MahdiBaghbani added this to the Release 0.6 milestone Mar 7, 2024
@MahdiBaghbani MahdiBaghbani self-assigned this Mar 7, 2024
@MahdiBaghbani
Copy link
Member Author

Possible fix:

<?php

declare(strict_types=1);

namespace OCA\ScienceMesh\AppInfo;

use OCA\ScienceMesh\Notifier\ScienceMeshNotifier;
use OCA\ScienceMesh\Plugins\ScienceMeshSearchPlugin;
use OCA\ScienceMesh\Service\UserService;
use OCA\ScienceMesh\ShareProvider\ScienceMeshShareProvider;
use OCP\AppFramework\App;
use OCP\IUserSession;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;


class ScienceMeshApp extends App
{
	/**
	 * @throws ContainerExceptionInterface
	 * @throws NotFoundExceptionInterface
	 */
	public function __construct()
	{
		parent::__construct("sciencemesh");

		$container = $this->getContainer();
		$server = $container->getServer();

		$container->registerService(UserService::class, function ($c) {
			return new UserService(
				$c->get(IUserSession::class)
			);
		});

		// currently logged-in user, userId can be gotten by calling the
		// getUID() method on it
		$container->registerService("User", function ($c) {
			return $c->get(IUserSession::class)->getUser();
		});

		$collaboration = $container->get("OCP\Collaboration\Collaborators\ISearch");
		$collaboration->registerPlugin(["shareType" => "SHARE_TYPE_REMOTE", "class" => ScienceMeshSearchPlugin::class]);

		$shareManager = $container->get("OCP\Share\IManager");
		$shareManager->registerShareProvider(ScienceMeshShareProvider::class);

		$notificationManager = $server->getNotificationManager();
		$notificationManager->registerNotifierService(ScienceMeshNotifier::class);
	}
}

@MahdiBaghbani
Copy link
Member Author

Now I see that version 28 breaks the search! 😞

@MahdiBaghbani MahdiBaghbani removed the critical Show-stopper for production label Mar 7, 2024
@mickenordin
Copy link

Presumably, fixing this will break OwnCloud compatibility? Maybe we should tag a new version where we can fix the nextcloud api breakage, and Owncloud users can use the older version?

@mickenordin
Copy link

Alot of things has changed: https://docs.nextcloud.com/server/latest/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.html

I can work on fixing them, but I can't promise to keep compatibility with OC 10.

@MahdiBaghbani
Copy link
Member Author

Hi Micke! Thanks for the help.

IMO ownCloud compatibility is not necessary, and since I've started testing oCIS in the past weeks I noticed we have to update the ScienceMesh app for Nextcloud.

I've created separate repos to work on them independently of each other (instead of forking this repo):

  1. https://github.com/MahdiBaghbani/sciencemesh-owncloud
  2. https://github.com/MahdiBaghbani/sciencemesh-nextcloud

Once fixing and testing are finished we can migrate it back to the ScienceMesh organization.

@mickenordin
Copy link

mickenordin commented Jul 29, 2024

Nice! Are you working on them now? If so, do you want to dived up the work somehow? Otherwise I can fork you repo and start poking around and submit pr's to your repo?

@MahdiBaghbani
Copy link
Member Author

I planned ScienceMesh for my weekend hobby 😄 project starting this week.

I appreciate your help on the Netxcloud as you are experienced with 28+ versions.

@mickenordin
Copy link

Sounds good, I can start to take a look on Nextcloud tomorrow in that case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants