jenkins-bot has submitted this change and it was merged. Change subject: Re-apply "Add PHP error logging to Sentry extension" ......................................................................
Re-apply "Add PHP error logging to Sentry extension" This re-applies commit bad0a30696330fea11521db0bacc784f53bf7288, which broke beta due to relying on a composer library not added to mediawiki/vendor, but I1f2179bd61fff3b794a8c4fdcb5e2f45324e12bb should have taken care of that. (This reverts cbf7c77208dddfd5bee852565b478e77d889ecbd.) Bug: T85188 Bug: T101252 Change-Id: I5fe94f746a95bcb9dd5b3a63e634cdd5dd5e83ec --- M .gitignore M Sentry.php M SentryHooks.php A composer.json 4 files changed, 45 insertions(+), 1 deletion(-) Approvals: BryanDavis: Looks good to me, approved Paladox: Looks good to me, but someone else must approve Hashar: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/.gitignore b/.gitignore index 3c3629e..e32f354 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -node_modules +node_modules/ +vendor/ +composer.lock + diff --git a/Sentry.php b/Sentry.php index f80f939..607ffdc 100644 --- a/Sentry.php +++ b/Sentry.php @@ -31,6 +31,8 @@ $wgHooks['BeforePageDisplay'][] = 'SentryHooks::onBeforePageDisplay'; $wgHooks['UnitTestsList'][] = 'SentryHooks::onUnitTestsList'; $wgHooks['ResourceLoaderTestModules'][] = 'SentryHooks::onResourceLoaderTestModules'; +$wgHooks['LogException'][] = 'SentryHooks::onLogException'; +SentryHooks::onRegistration(); /** * Sentry DSN (http://raven.readthedocs.org/en/latest/config/#the-sentry-dsn) @@ -52,3 +54,9 @@ */ $wgSentryLogOnError = true; +/** + * Log PHP errors automatically. + * @var bool + */ +$wgSentryLogPhpErrors = true; + diff --git a/SentryHooks.php b/SentryHooks.php index c653f8a..d8b8031 100644 --- a/SentryHooks.php +++ b/SentryHooks.php @@ -56,4 +56,24 @@ } return substr( $dsn, 0, $colon_pos ) . substr( $dsn, $at_pos ); } + + public static function onRegistration() { + if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + require_once( __DIR__ . '/vendor/autoload.php' ); + } + } + + public static function onLogException( Exception $e ) { + global $wgSentryDsn, $wgSentryLogPhpErrors; + + if ( !$wgSentryLogPhpErrors ) { + return true; + } + + $client = new Raven_Client( $wgSentryDsn ); + $client->captureException( $e ); + + return true; + } } + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4cb5c4a --- /dev/null +++ b/composer.json @@ -0,0 +1,13 @@ +{ + "name": "mediawiki/sentry", + "type": "mediawiki-extension", + "description": "Send MediaWiki errors to Sentry, a realtime, platform-agnostic error logging and aggregation platform", + "keywords": ["MediaWiki", "Sentry", "error logging"], + "homepage": "https://www.mediawiki.org/wiki/Extension:Sentry", + "license" : "MIT", + + "require": { + "composer/installers": ">=1.0.1", + "raven/raven": "0.12.0" + } +} -- To view, visit https://gerrit.wikimedia.org/r/216753 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5fe94f746a95bcb9dd5b3a63e634cdd5dd5e83ec Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Sentry Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits