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

exception in 2.0.1 #7

Open
justinholtweb opened this issue Sep 27, 2024 · 10 comments
Open

exception in 2.0.1 #7

justinholtweb opened this issue Sep 27, 2024 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@justinholtweb
Copy link

In the 2.0.1 version on Craft 4.12.1 - the main plugin file throws an exception on the handleException method -- PHP Warning ‘yii\base\ErrorException’ with message ‘Attempt to read property “sentry” on null’ in /var/www/html/vendor/statikbe/craft-sentry/src/Sentry.php:74

Editing the main plugin class method handleException to call the main class with self::$plugin->handleException($exception); instead of Sentry::$plugin->sentry->handleException($exception); fixes this issue, but since your main and develop branches are both on 5.0.0 I don't know how to submit a PR for 2.0.1 which is used on Craft 4.

@cherrykoda
Copy link

Ran into this issue - if the edit can be made to the Craft 4.0 version (heads up that the README title needs to be updated on that branch too ... it says its for the 3.0 version) that would be awesome to ensure we have no future issues.

With Craft 4 still being an active release it makes sense to patch :)

@janhenckens janhenckens self-assigned this Sep 30, 2024
@janhenckens
Copy link
Member

Yes, makes sense to patch - I'll have a look and try to get a fix out asap!

@janhenckens
Copy link
Member

Editing the main plugin class method handleException to call the main class with self::$plugin->handleException($exception); instead of Sentry::$plugin->sentry->handleException($exception); fixes this issue,

@justinholtweb that might remove the error but it will break the plugin I think. The initial code (Sentry::getInstance()->sentry->handleException($exception);) refers to a handleException function on the SentryService, where your change (self::$plugin->handleException($exception);) refers back to the function you're in at that point, creating a loop...

@janhenckens
Copy link
Member

Hey @justinholtweb @cherrykoda, I pushed an update with some changes related to this (2.1.1) but couldn't reproduce the issue myself. We recently started adding the plugin to all are builds and haven't seen this error there either...

Can you try the latest release and see if that changes anything?

@justinholtweb
Copy link
Author

justinholtweb commented Oct 2, 2024

@janhenckens has 2.1.1 been released? I don't see it in releases and can't install that version locally. I do see 2.1.0, is that the proper release?

@justinholtweb
Copy link
Author

@janhenckens Installing 2.1.0 results in the following error:

Exception 'Error' with message 'Call to a member function getSettings() on null'

in /var/www/html/vendor/statikbe/craft-sentry/src/Sentry.php:76

Stack trace:
#0 /var/www/html/modules/sitemodule/src/Sitemodule.php(85): statikbe\sentry\Sentry::handleException(Object(yii\base\InvalidConfigException))
#1 [internal function]: modules\sitemodule\Sitemodule->__construct('sitemodule', Object(craft\console\Application), Array)
#2 /var/www/html/vendor/yiisoft/yii2/di/Container.php(411): ReflectionClass->newInstanceArgs(Array)
#3 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('modules\sitemod...', Array, Array)
#4 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('modules\sitemod...', Array, Array)
#5 /var/www/html/vendor/yiisoft/yii2/base/Module.php(445): yii\BaseYii::createObject(Array, Array)
#6 /var/www/html/vendor/yiisoft/yii2/base/Application.php(313): yii\base\Module->getModule('sitemodule')
#7 /var/www/html/vendor/craftcms/cms/src/console/Application.php(66): yii\base\Application->bootstrap()
#8 /var/www/html/vendor/yiisoft/yii2/base/Application.php(271): craft\console\Application->bootstrap()
#9 /var/www/html/vendor/yiisoft/yii2/console/Application.php(124): yii\base\Application->init()
#10 /var/www/html/vendor/craftcms/cms/src/console/Application.php(52): yii\console\Application->init()
#11 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#12 /var/www/html/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#13 /var/www/html/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#14 [internal function]: yii\console\Application->__construct(Array)
#15 /var/www/html/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#16 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\console\A...', Array, Array)
#17 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\console\A...', Array, Array)
#18 /var/www/html/vendor/craftcms/cms/src/Craft.php(59): yii\BaseYii::createObject(Array, Array)
#19 /var/www/html/vendor/craftcms/cms/bootstrap/bootstrap.php(260): Craft::createObject(Array)
#20 /var/www/html/vendor/craftcms/cms/bootstrap/console.php(42): require('/var/www/html/v...')
#21 /var/www/html/craft(12): require('/var/www/html/v...')
#22 {main}`

@cherrykoda
Copy link

While I am seeing a 2.1.1 tag here on github, its not findable in composer.

Problem 1
- Root composer.json requires statikbe/craft-sentry 2.1.1 (exact version match: 2.1.1 or 2.1.1.0), found statikbe/craft-sentry[dev-master, dev-craft4, dev-develop, 1.0.0, ..., 1.1.0, 2.0.0-beta.1, 2.0.0, 2.0.1, 2.1.0, 5.0.0-alpha.1, 5.0.0, 5.1.0] but it does not match the constraint.

I did make the edit manually (the one on 2.1.1 compared to 2.1.0) with no effect to the outcome. The System is on:

  • PHP 8.2.15
  • Maria DB 11.1.2
  • Craft CMS Pro 4.12.1
  • Craft Commerce 4.6.11
  • Sentry.io Plugin 2.1.0

Other Notable Plugins:

  • Blitz
  • Craft Commerce
  • Element API
  • Imager X
  • And others...

@janhenckens
Copy link
Member

Forgot to push 2.1.1, sorry about that - should be available now!

Are you seeing the error when an exception happens or on any page?

@cherrykoda
Copy link

cherrykoda commented Oct 4, 2024

@janhenckens this is on throwing an exception, and 2.1.1 is still not installing via composer (sorry!)

Edited to add exception code (from README example):

        // Sentry Test Exception (guaranteed failure for logging)
        try {
            throw new InvalidConfigException("test");
        } catch (InvalidConfigException $e) {
            Sentry::handleException($e);
        }

@janhenckens
Copy link
Member

Hey @justinholtweb @cherrykoda, I was any from the office for a couple of weeks and sort of forgot about this issue - if this is still happening in your project(s), would you be open to sharing the composer.json, composer.lock & database so we can try to reproduce it on our end?

@janhenckens janhenckens added the question Further information is requested label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants