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

Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given #79

Closed
GammaPi opened this issue Sep 4, 2019 · 8 comments

Comments

@GammaPi
Copy link
Contributor

GammaPi commented Sep 4, 2019

Every time I call index, this message appears
#27 seems to be related

NC 16.02 Fulltext Search Plugin 1.3.6
#27 looks like a similar error

An unhandled exception has been thrown:
TypeError: Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given, called in /var/www/html/custom_apps/files_fulltextsearch/lib/Service/ExternalFilesService.php on line 244 and defined in /var/www/html/custom_apps/files_fulltextsearch/lib/Service/ExternalFilesService.php:258
Stack trace:
#0 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/ExternalFilesService.php(244): OCA\Files_FullTextSearch\Service\ExternalFilesService->getExternalMountById(NULL)
#1 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/ExternalFilesService.php(187): OCA\Files_FullTextSearch\Service\ExternalFilesService->getMountPoint(Object(OC\Files\Node\Folder))
#2 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/FilesService.php(673): OCA\Files_FullTextSearch\Service\ExternalFilesService->updateDocumentAccess(Object(OCA\Files_FullTextSearch\Model\FilesDocument), Object(OC\Files\Node\Folder))
#3 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/FilesService.php(650): OCA\Files_FullTextSearch\Service\FilesService->updateDocumentAccess(Object(OCA\Files_FullTextSearch\Model\FilesDocument), Object(OC\Files\Node\Folder))
#4 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/FilesService.php(631): OCA\Files_FullTextSearch\Service\FilesService->updateFilesDocumentFromFile(Object(OCA\Files_FullTextSearch\Model\FilesDocument), Object(OC\Files\Node\Folder))
#5 /var/www/html/custom_apps/files_fulltextsearch/lib/Service/FilesService.php(522): OCA\Files_FullTextSearch\Service\FilesService->updateFilesDocument(Object(OCA\Files_FullTextSearch\Model\FilesDocument))
#6 /var/www/html/custom_apps/files_fulltextsearch/lib/Provider/FilesProvider.php(272): OCA\Files_FullTextSearch\Service\FilesService->generateDocument(Object(OCA\Files_FullTextSearch\Model\FilesDocument))
#7 /var/www/html/custom_apps/fulltextsearch/lib/Service/IndexService.php(314): OCA\Files_FullTextSearch\Provider\FilesProvider->fillIndexDocument(Object(OCA\Files_FullTextSearch\Model\FilesDocument))
#8 /var/www/html/custom_apps/fulltextsearch/lib/Service/IndexService.php(205): OCA\FullTextSearch\Service\IndexService->indexDocuments(Object(OCA\FullTextSearch_ElasticSearch\Platform\ElasticSearchPlatform), Object(OCA\Files_FullTextSearch\Provider\FilesProvider), Array, Object(OCA\FullTextSearch\Model\IndexOptions))
#9 /var/www/html/custom_apps/fulltextsearch/lib/Command/Index.php(409): OCA\FullTextSearch\Service\IndexService->indexProviderContentFromUser(Object(OCA\FullTextSearch_ElasticSearch\Platform\ElasticSearchPlatform), Object(OCA\Files_FullTextSearch\Provider\FilesProvider), 'tjx', Object(OCA\FullTextSearch\Model\IndexOptions))
#10 /var/www/html/custom_apps/fulltextsearch/lib/Command/Index.php(273): OCA\FullTextSearch\Command\Index->indexProvider(Object(OCA\Files_FullTextSearch\Provider\FilesProvider), Object(OCA\FullTextSearch\Model\IndexOptions))
#11 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\FullTextSearch\Command\Index->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/core/Command/Base.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(901): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/3rdparty/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(OCA\FullTextSearch\Command\Index), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/3rdparty/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/console.php(97): OC\Console\Application->run()
#18 /var/www/html/occ(11): require_once('/var/www/html/c...')

@GammaPi
Copy link
Contributor Author

GammaPi commented Sep 8, 2019

Clearly this is caused by a not properly handled exception. I'm trying a quick and dirty fix. However, this solution should be further checked because I have no idea why "$file->getMountPoint()->getMountId()" is null.

Edit: NextcloudHomeFolder/custom_apps/files_fulltextsearch/lib/Service/ExternalFilesService.php

Find the following function, and add the if part!

        /**
         * @param Node $file
         *
         * @return MountPoint
         * @throws FileIsNotIndexableException
         */
        private function getMountPoint(Node $file): MountPoint {

                try {
                        if($file->getMountPoint()->getMountId() === null){
                             throw new FileIsNotIndexableException('getMountId is null');
                        }
                        return $this->getExternalMountById(
                                $file->getMountPoint()
                                         ->getMountId()
                        );
                } catch (ExternalMountNotFoundException $e) {
                        throw new FileIsNotIndexableException('issue while getMountPoint');
                }
        }

@GammaPi
Copy link
Contributor Author

GammaPi commented Sep 8, 2019

@daita would you please look into this?

@GammaPi
Copy link
Contributor Author

GammaPi commented Sep 8, 2019

Fulltextsearch continue to work again after the fix~~ Maybe I should open a pull request about this~

@thloe1
Copy link

thloe1 commented Sep 22, 2019

I got this error, too.

However, this solution should be further checked because I have no idea why "$file->getMountPoint()->getMountId()" is null.

I have mounted External CIFS storage to the root ("/") of my Nextcloud folders (see nextcloud/server#3438). Maybe this is causing the issue.

@derritter88
Copy link

@GammaPi Thanks Gamma - saved me hours of bug finding (and probably a few more grey hairs)

@GammaPi GammaPi changed the title TypeError: Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given (Solved)TypeError: Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given Mar 27, 2020
@saniwat
Copy link

saniwat commented May 13, 2020

I'm wondering regarding the status. At this very moment the indexing is not working as soon a private (=> user generated) external storage is existing.

@GammaPi: Of course the fix work ignoring all files having no MountId, but as a result no files from user created external storage is indexed.

I'm not a PHP developer to fix it. To my understanding the problem is that private external storage are "MoveableMount" not providing the ID.

@GammaPi
Copy link
Contributor Author

GammaPi commented May 15, 2020

@saniwat
I'm not a PHP guy either. Thank you for your comments anyway, and perhaps the developer will notice this after some time. But if you think you find a new issue, I think it would be better to create a seperate issue and cite #79 for more attention from the developer.
From my observation, my fix is no longer required after recent update, because the implementation of this function have some changes.
Problem still exists.
getExternalMountById's location changed a bit in the sourcecode.

@solracsf solracsf changed the title (Solved)TypeError: Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given Argument 1 passed to OCA\Files_FullTextSearch\Service\ExternalFilesService::getExternalMountById() must be of the type int, null given Sep 15, 2021
@joshtrichards
Copy link
Member

Fixed in #80 (and possibly elsewhere).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants