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

PHP Warning: Invalid argument supplied for foreach() in vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php on line 1104 #91

Closed
philyuska opened this issue Jan 1, 2023 · 19 comments

Comments

@philyuska
Copy link

philyuska commented Jan 1, 2023

when teamdrive is enabled i start getting these warnings when checking directory existence via Storage::disk('google')->getAdapter()->hasDir('directory')

also get the same warnings from flysystem-google-drive-ext/src/GoogleDriveAdapter.php on line 981

looks like $object->getPermissions() in function normaliseObject and $file->getPermissions() in function getRawVisibility are both returning null

@parallels999
Copy link

The information is not complete, feel free to make a PR to fix that

@philyuska
Copy link
Author

apologies, i'm a bit of a newbie at this.
i'm using Laravel 7 w PHP version 7.4.2

filesystems.php is configured thusly:

        'google' => [
            'driver' => 'google',
            'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
            'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
            'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
            'teamDriveId' => env('GOOGLE_DRIVE_TEAM_DRIVE_ID'),
            'folder' => env('GOOGLE_DRIVE_FOLDER'),
        ]

running the command Storage::disk('google')->getAdapter()->hasDir('[ valid directory name]') in the artisan tinker console those php warnings are generated.

i was able to trace it back to those 2 functions.

also to note, this does not occur when using a standard/non-team google drive folder

If by PR you mean problem report, i thought that is what i was doing here. If there is some other way i should report this, please let me know and i would be happy to do so

@parallels999
Copy link

PR means PULL REQUEST

Also do you have the latest version of this package? there is no foreach on line 1104

protected function splitFileExtension($name)

Laravel 7 has no support at this time, it did reaches his end of life since 2021

@philyuska
Copy link
Author

i followed the instructions for Flysystem V1 or Laravel <= 8.x.x use 1.x.x version of the package
composer require masbug/flysystem-google-drive-ext:"^1.0.0"

okay, i'll try when i upgrade to Laravel 9

@philyuska
Copy link
Author

Same issue after upgrading to Laravel Framework 9.46.0 and masbug/flysystem-google-drive-ext v2.2.2

Storage::disk('google')->getAdapter()->hasDir('valid directory')

WARNING foreach() argument must be of type array|object, null given in vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php on line 1166.

= [
"hasdir" => true,
]

@parallels999
Copy link

Avoid "hasdir" => true,

And try

Storage::disk('google')->getAdapter()->directoryExists('valid directory');

@philyuska
Copy link
Author

still get the same warnings

# #> Storage::disk('google')->getAdapter()->directoryExists('valid directory');

   WARNING  foreach() argument must be of type array|object, null given in vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php on line 1166.

= true

@parallels999
Copy link

Maybe it is something on your implementation, it is working for me
here is a demo https://github.com/erikn69/laravel-google-drive-ext-demo
Make a debug or make a failing test demonstrating the problem,
and feel free to make a PR to fix that

@philyuska
Copy link
Author

are you using a teamDriveId? in that link it is commented out

@parallels999
Copy link

are you using a teamDriveId?

Yes

@philyuska
Copy link
Author

using that demo project when i try the list-files route i get and exception
Unable to read file from location: [my team drive id] File not found

the list-team-drives route works okay and that is the team drive id i have defined in .env

@philyuska
Copy link
Author

i did

@angeljqv
Copy link

Hi, if you know the line of the bug, make a fix and send a pull request, maybe the authors won't be able to replicate your problem

@philyuska
Copy link
Author

philyuska commented Jan 13, 2023

sadly i don't.
the put route successfully creates a file, but when i try list-files get that file not found exception. this is what is being recorded in the laravel log

[2023-01-13 18:02:09] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:200)
[stacktrace]
#0 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(125): Illuminate\Log\LogManager->resolve()
#1 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#3 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(249): Illuminate\Log\LogManager->error()
#4 /var/www/html/laravel-google-drive-demo/app/Exceptions/Handler.php(35): Illuminate\Foundation\Exceptions\Handler->report()
#5 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): App\Exceptions\Handler->report()
#6 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Routing\Pipeline->handleException()
#7 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#8 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#9 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#10 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#11 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#12 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#13 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#14 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
#15 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle()
#16 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#18 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#20 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#21 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Pipeline\Pipeline->then()
#22 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router->runRouteWithinStack()
#23 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRoute()
#24 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router->dispatchToRoute()
#25 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Routing\Router->dispatch()
#26 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#27 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#28 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#29 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
#30 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#31 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#32 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
#33 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#34 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#35 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#36 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#37 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#38 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()
#39 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#40 /var/www/html/laravel-google-drive-demo/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle()
#41 {main}
"}
[2023-01-13 18:02:09] laravel.ERROR: Unable to read file from location: 0ABq__YFDHH0kUk9PVA. File not found {"exception":"[object] (League\Flysystem\UnableToReadFile(code: 0): Unable to read file from location: 0ABq__YFDHH0kUk9PVA. File not found at /var/www/html/laravel-google-drive-demo/vendor/league/flysystem/src/UnableToReadFile.php:24)
[stacktrace]
#0 /var/www/html/laravel-google-drive-demo/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(1869): League\Flysystem\UnableToReadFile::fromLocation()
#1 /var/www/html/laravel-google-drive-demo/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(1967): Masbug\Flysystem\GoogleDriveAdapter->makeFullVirtualPath()
#2 /var/www/html/laravel-google-drive-demo/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(805): Masbug\Flysystem\GoogleDriveAdapter->toVirtualPath()
#3 [internal function]: Masbug\Flysystem\GoogleDriveAdapter->listContents()
#4 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(987): iterator_to_array()
#5 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(42): Illuminate\Support\Collection->getArrayableItems()
#6 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Collections/helpers.php(18): Illuminate\Support\Collection->__construct()
#7 /var/www/html/laravel-google-drive-demo/routes/web.php(34): collect()
#8 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Route.php(237): Illuminate\Routing\RouteFileRegistrar->{closure}()
#9 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Route.php(207): Illuminate\Routing\Route->runCallable()
#10 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\Routing\Route->run()
#11 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#12 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#14 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#15 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#16 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#18 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
#20 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle()
#21 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#22 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#23 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#24 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#25 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#26 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Pipeline\Pipeline->then()
#27 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router->runRouteWithinStack()
#28 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRoute()
#29 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router->dispatchToRoute()
#30 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Routing\Router->dispatch()
#31 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#32 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#34 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
#35 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#36 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#37 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
#38 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#39 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#40 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#41 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#42 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#43 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()
#44 /var/www/html/laravel-google-drive-demo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#45 /var/www/html/laravel-google-drive-demo/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle()

@angeljqv
Copy link

angeljqv commented Jan 13, 2023

GoogleDriveAdapter.php on line 1104

So, make a debug, find the problem, fix it, and then make the pull request

@philyuska
Copy link
Author

apologies again, i'm a bit of a newbie at this, once i figure out how to submit a PR i will gladly do so.

I have found my issue, the google drive api version 3 deprecated includeTeamDriveItems and replaced it with supportsAllDrives. the valid corpora bodies are user, domain, drive, and allDrives.

i was able to resolve my issue by updating these functions

    public function enableTeamDriveSupport()
    {
        $this->optParams = array_merge_recursive(
            array_fill_keys([
                'files.copy', 'files.create', 'files.delete',
                'files.trash', 'files.get', 'files.list', 'files.update',
                'files.watch', 'permissions.list'
            ], ['supportsAllDrives' => true]),
            $this->optParams
        );
    }
    public function setTeamDriveId($teamDriveId, $corpora = 'drive')
    {
        $this->enableTeamDriveSupport();
        $this->optParams = array_merge_recursive($this->optParams, [
            'files.list' => [
                'corpora' => $corpora,
                'includeItemsFromAllDrives' => true,
                'driveId' => $teamDriveId
            ]
        ]);

        if ($this->root === 'root' || $this->root === null) {
            $this->setPathPrefix('');
            $this->root = $teamDriveId;
        }
    }

as for my original issue, $object->getPermissions() is still returning null however i was able to resolve the issue using the logic submitted in PR #92 in the normalizeObject function.

@angeljqv
Copy link

That functions are already updated, You are probably not using the latest version.

public function enableTeamDriveSupport()
{
$this->optParams = array_merge_recursive(
array_fill_keys([
'files.copy', 'files.create', 'files.delete',
'files.trash', 'files.get', 'files.list', 'files.update',
'files.watch', 'permissions.list'
], ['supportsAllDrives' => true]),
$this->optParams
);
}

public function setTeamDriveId($teamDriveId, $corpora = 'drive')
{
$this->enableTeamDriveSupport();
$this->optParams = array_merge_recursive($this->optParams, [
'files.list' => [
'corpora' => $corpora,
'includeItemsFromAllDrives' => true,
'driveId' => $teamDriveId
]
]);
if ($this->root === 'root' || $this->root === null) {
$this->setPathPrefix('');
$this->root = $teamDriveId;
}
}

@masbug
Copy link
Owner

masbug commented Mar 9, 2023

Merged.

@masbug masbug closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants