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

EventWatcher throws error when project is run through google drive when determining if string has the '@' symbol. #1517

Open
lucas-quinn-guru opened this issue Sep 10, 2024 · 1 comment

Comments

@lucas-quinn-guru
Copy link

Telescope Version

5.2.2

Laravel Version

11.22.0

PHP Version

8.2

Database Driver & Version

PostgreSQL 15.1 on aarch64-apple-darwin22.1.0, compiled by Apple clang version 12.0.5 (clang-1205.0.22.9), 64-bit

Description

Google Drives stores directory structure under a users email address which catches an error during a class_implements() check since code is using the @ as a delimiter and string check.

I was able to fix this locally, but not sure it it's correct by adding GoogleDrive as an option to reject().

`protected function formatListeners($eventName)
{
return collect(app('events')->getListeners($eventName))
->map(function ($listener) {
$listener = (new ReflectionFunction($listener))
->getStaticVariables()['listener'];

            if (is_string($listener)) {
                return Str::contains($listener, '@') ? $listener : $listener.'@handle';
            } elseif (is_array($listener) && is_string($listener[0])) {
                return $listener[0].'@'.$listener[1];
            } elseif (is_array($listener) && is_object($listener[0])) {
                return get_class($listener[0]).'@'.$listener[1];
            } elseif (is_object($listener) && is_callable($listener) && ! $listener instanceof Closure) {
                return get_class($listener).'@__invoke';
            }

            return $this->formatClosureListener($listener);
        })->reject(function ($listener) {
            if( Str::contains($listener, 'Laravel\\Telescope') || Str::contains($listener, 'GoogleDrive') ) {
                return true;
            }
            return false;
        })->map(function ($listener) {
            if (Str::contains($listener, '@') ) {
                $queued = in_array(ShouldQueue::class, class_implements(Str::beforeLast($listener, '@')));
            }

            return [
                'name' => $listener,
                'queued' => $queued ?? false,
            ];
        })->values()->toArray();
}`

Steps To Reproduce

run any project with telescope and filamentphp installed stored and run from GoogleDrive.

@lucas-quinn-guru lucas-quinn-guru changed the title EventWatcher throws error project is run through google drive when determining if string has the '@' symbol. EventWatcher throws error when project is run through google drive when determining if string has the '@' symbol. Sep 10, 2024
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

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

2 participants