nextcloud-grauphel
nextcloud-grauphel copied to clipboard
Logging error Declaration of OCA\Grauphel.. must be compatible..
After upgrading to [Nextcloud Hub 3] (25.0.4) and Grauphel 1.0.18 i receive plenty of errors in NC Logging:
Declaration of OCA\Grauphel\Search\Provider::search(OCA\Grauphel\Search\OCP\IUser $user, OCA\Grauphel\Search\OCP\Search\ISearchQuery $query) must be compatible with OCP\Search\IProvider::search(OCP\IUser $user, OCP\Search\ISearchQuery $query): OCP\Search\SearchResult at /var/www/html/custom_apps/grauphel/lib/Search/Provider.php#44
At the same time clients are experiencing sync problems, they cannot connect.
On previous versions there were no such errors, but as I upgraded Nextcloud and Grauphel at the same time I can't specify which one was the cause now. Thank you for hints and help!
I made custom research and found out, that the culprit lies in profound differencies in the versions maintained by Nextcloud, especially the 1.0.18 https://apps.nextcloud.com/apps/grauphel and the current code state in this git repo..
The error above comes from missing ": SearchResult" in the
var/www/html/custom_apps/grauphel/lib/Search/Provider.php#44
file
public function search(OCP\IUser $user, OCP\Search\ISearchQuery $query)
and the correct way
public function search(IUser $user, ISearchQuery $query) : SearchResult
This file is from the official version 1.0.18. The Provider.php in this git codebase is correct.
By correcting the missing declaration there is a waterfall off other errors only revealing themselves after this fix.
The next is
Could not check compatibility between OCA\Grauphel\Search\Provider::search(OCA\Grauphel\Search\OCP\IUser $user, OCA\Grauphel\Search\OCP\Search\ISearchQuery $query): OCA\Grauphel\Search\OCP\Search\SearchResult and OCP\Search\IProvider::search(OCP\IUser $user, OCP\Search\ISearchQuery $query): OCP\Search\SearchResult, because class OCA\Grauphel\Search\OCP\IUser is not available at /var/www/html/custom_apps/grauphel/lib/Search/Provider.php#44
This again has to do with the "OCP\IUser" namespace declaration in the search function. It has to be "IUser" only.
Again this occurs only in official version.
After fixing IUser there is another one
Undefined constant OCA\Grauphel\AppInfo\Application::APP_ID in file '/var/www/html/custom_apps/grauphel/lib/Search/Provider.php' line 27
(fixed in current git code, it is a missing declaration in AppInfo/Application.php..)
and
Undefined constant OCA\Grauphel\Search\Provider::ORDER in file '/var/www/html/custom_apps/grauphel/lib/Search/Provider.php' line 46
which I did not find anywhere what it is meant to do. For testing I replaced
return self::ORDER;
with
return 1;
The self::ORDER constant is not being defined anywhere..
I updated the whole app code to this git code here but then there is another errors:
Undefined property: OCA\Grauphel\Search\Provider::$lutil at /var/www/html/custom_apps/grauphel/lib/Search/Provider.php#36
So again for the sake of testing i replaced
return $this->lutil->l10n->t('Grauphel');
with
return 'Grauphel';
Sorry for pasting all the errors and quirks here, but hopefully somebody makes use of it and maybe there is an update which could solve all this in one go. Thank you grosjo for taking over this awesome project :)