Closed jhit closed 3 years ago
Sorry kann ich nicht reproduzieren. Welche Shopware Version? Wie ist das Plugin installiert (composer o.ä.)
Kann den Fehler bestätigen. War bei uns auch mit Shopware 5.6.8 und der neuesten Plugin-Version. Cache-Verzeichnis manuell leeren hat auch nichts geändert. Edit: Plugin wurde ohne composer aus Store-Release integriert
@hhoechtl Entschuldige bitte die dünne Info. Shopware 5.6.7 OdSentry 2.0.1 => 2.0.4 aktualisiert Plugin über Update Funktion im Shop installiert. Danach verzeichnis gelöscht. ZIP Datei aus den SW Account geladen und nochmal frisch ins Verzeichnis entpackt. Hatte den selben Fehler in 2 getrennten Shop Instanzen.
Ich hab noch nen Fehler gefunden in dem Store release, aber der mit dem hier nix zu tun => es gibt jetzt 2.0.5.
Der composer autoload Fehler der hier beschrieben wird, kann ich wirklich auf keiner unserer Instanzen nachstellen, auch nicht auf denen mit der Store-Version des Plugins.
Im Plugin steckt ja ein composer package inkl. Autoloader, dass so eingebunden ist:
if (file_exists($this->pluginDirectory . '/vendor/autoload.php')) {
require_once $this->pluginDirectory . '/vendor/autoload.php';
}
Mehr kann ich da nicht machen. Der Rest ist composer interna bzw. irgendwas merkwürdiges mit deinem System. Falls du es rausfindest, sag mir bescheid.
@hhoechtl Ich habe die neue Version getestet. Erst im Testshop und dann im Liveshop. Eine Weile lief es fehlerfrei. Ich habe den Eindruck dass es erst fehlerfrei läuft und wenn die erste Exception ausgelöst wird, dann gibt es einen Fehler und danach funktioniert das Plugin garnicht mehr und jeder Aufruf auf den Shop löst den oben genannten Fehler aus.
Ich hab in unseren Testshops auch mehrere Exceptions provoziert. Funktionierte durchgehend. Wieso sollte auch plötzlich der Autoloader weg sein bzw nicht mehr funktionieren :man_shrugging:
Ich hab keine Ahnung warum das passiert. Eventuell weil Proxy Caches auslaufen? Ich hab das Verhalten jetzt mehrfach gesehen. Man installiert das Plugin neu, leert Caches. Dann funktioniert alles eine Weile und plötzlich gibt es wieder den Fehler "Class 'Sentry\ClientBuilder' not found", der dann bleibt und bei jedem Shop aufruf geworfen wird.
Hast du eine Idee wie ich das debuggen könnte?
Das hat mit den Proxy-Caches aber nix zu tun.
Einzige Möglichkeit das zu debuggen wäre eigentlich wenn es mal kaputt ist an der Stelle wo der autoloader geladen wird zu schauen ob das geht: https://github.com/1drop/shopware-sentry/blob/v2/Subscriber/ErrorHandler.php#L66
Der Autoloader selbst ist im Plugin festgeschrieben => es kann nicht sein, dass der einmal geht und einmal nicht.
@jhit hast du noch irgendwas zu dem Problem herausfinden können?
@larsbo ja, ich hab mir nen Breakpoint da gesetzt wo Hans das vorgeschlagen hat. Der Autoloader wird aufgerufen, die Datei geladen und der Fehler kommt trotzdem. Ich steige nicht durch. Kann es sein dass der namespace im autoloader irgendwie falsch gesetzt wird? Ich hab Sentry letztendlich beim Kunden entfernt.
Sehr merkwürdig. Vielleicht ein seltsames APCu Problem?
Ich hab Sentry letztendlich beim Kunden entfernt.
Das war auch meine "Lösung" vorerst. Hatte nur gehofft, dass vielleicht noch jemand eine Idee hat.
A composer update
in the plugin directory works fine for me....
composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 13 updates, 2 removals
- Removing composer/package-versions-deprecated (1.11.99)
- Removing paragonie/random_compat (v9.99.99)
- Upgrading composer/installers (v1.9.0 => v1.10.0)
- Upgrading guzzlehttp/promises (1.4.0 => 1.4.1)
- Upgrading guzzlehttp/psr7 (1.7.0 => 1.8.1)
- Upgrading jean85/pretty-package-versions (1.5.1 => 2.0.3)
- Upgrading php-http/discovery (1.12.0 => 1.13.0)
- Upgrading php-http/message (1.9.0 => 1.11.0)
- Upgrading psr/container (1.0.0 => 1.1.1)
- Upgrading sentry/sentry (2.5.0 => 2.5.2)
- Upgrading symfony/http-client (v4.4.15 => v4.4.21)
- Upgrading symfony/options-resolver (v4.4.15 => v4.4.20)
- Upgrading symfony/polyfill-php73 (v1.18.1 => v1.22.1)
- Upgrading symfony/polyfill-php80 (v1.18.1 => v1.22.1)
- Upgrading symfony/polyfill-uuid (v1.18.1 => v1.22.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 13 updates, 2 removals
- Downloading composer/installers (v1.10.0)
- Downloading psr/container (1.1.1)
- Downloading symfony/polyfill-php73 (v1.22.1)
- Downloading symfony/http-client (v4.4.21)
- Downloading symfony/polyfill-uuid (v1.22.1)
- Downloading symfony/options-resolver (v4.4.20)
- Downloading guzzlehttp/psr7 (1.8.1)
- Downloading php-http/message (1.11.0)
- Downloading php-http/discovery (1.13.0)
- Downloading symfony/polyfill-php80 (v1.22.1)
- Downloading jean85/pretty-package-versions (2.0.3)
- Downloading guzzlehttp/promises (1.4.1)
- Downloading sentry/sentry (2.5.2)
- Removing paragonie/random_compat (v9.99.99)
- Removing composer/package-versions-deprecated (1.11.99)
- Upgrading composer/installers (v1.9.0 => v1.10.0): Extracting archive
- Upgrading psr/container (1.0.0 => 1.1.1): Extracting archive
- Upgrading symfony/polyfill-php73 (v1.18.1 => v1.22.1): Extracting archive
- Upgrading symfony/http-client (v4.4.15 => v4.4.21): Extracting archive
- Upgrading symfony/polyfill-uuid (v1.18.1 => v1.22.1): Extracting archive
- Upgrading symfony/options-resolver (v4.4.15 => v4.4.20): Extracting archive
- Upgrading guzzlehttp/psr7 (1.7.0 => 1.8.1): Extracting archive
- Upgrading php-http/message (1.9.0 => 1.11.0): Extracting archive
- Upgrading php-http/discovery (1.12.0 => 1.13.0): Extracting archive
- Upgrading symfony/polyfill-php80 (v1.18.1 => v1.22.1): Extracting archive
- Upgrading jean85/pretty-package-versions (1.5.1 => 2.0.3): Extracting archive
- Upgrading guzzlehttp/promises (1.4.0 => 1.4.1): Extracting archive
- Upgrading sentry/sentry (2.5.0 => 2.5.2): Extracting archive
Generating autoload files
11 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Update after first Exception
Now i get 'PHP message: PHP Parse error: syntax error, unexpected ''Method %s() is deprecated sin' (T_ENCAPSED_AND_WHITESPACE)
in ClientBuilder.php on line 155
.....
Seems to be the Hotfix in OdSentry/Subscriber/ErrorHandler.php
which manipulates the code in vendor/sentry/sentry/src/ClientBuilder.php
during the first exception. (??)
// Hot fix the ClientBuilder of the sentry sdk if the SDK is not installed via composer but bundled in the plugin
if (class_exists('\PackageVersions\Versions') && !isset(Versions::VERSIONS['sentry/sdk']) && is_dir($this->pluginDirectory . '/vendor')) {
$composerLock = json_decode(file_get_contents($this->pluginDirectory . '/composer.lock'), true);
$sentryPackage = current(array_filter($composerLock['packages'], function(array $package) {
return $package['name'] === 'sentry/sentry';
}));
$sentryVersion = $sentryPackage['version'];
$this->replaceFileContent(
$this->pluginDirectory . '/vendor/sentry/sentry/src/ClientBuilder.php',
'PrettyVersions::getVersion(\'sentry/sentry\')->getPrettyVersion()',
"'" . $sentryVersion . "'"
);
$this->replaceFileContent(
$this->pluginDirectory . '/vendor/sentry/sentry/src/Event.php',
'PrettyVersions::getVersion(\'sentry/sentry\')->getPrettyVersion()',
"'" . $sentryVersion . "'"
);
}
I commented out the hotfix and replaced the functions calls PrettyVersions::getVersion()
with a static version string.
I suggest to do this in build stage before testing and deploying the plugin to the Shopware market place.
I can reproduce the same error Class 'Sentry\\ClientBuilder' not found
with version 2.0.5 and shopware 5.6.10, installed from shopware store (without composer).
@christophlehmann was right. The problem is caused by the hotfix in the Subscriber. The replacement seems to work for the Event.php file but not for the ClientBuilder.php file. This can be easily verified using git. After activation of the sentry plugin and a page reload you can see that the full content of ClientBuilder.php has been removed from the file:
@hhoechtl maybe a PHP version specific problem? It looks like t does not work with PHP 7.4.21.
I was able to reproduce this issue today at one customer. This was caused by concurrent file access. I've added a .is_patched
flag file to the plugin that ensures that the sentry SDK files are patched only once.
2.1.0 which is compatible with Shopware 5.7 will be released to the store in the next couple of hours.
@hhoechtl I read your commit from Sep. 1. What is the reason you removed Support for SW 5.6?
Because SW 5.6 contains a hard dependency on an incompatible Guzzle client version for any current sentry SDK.
I'm on Shopware 5.6.7 but would still like to use the plugin. Is it possible to use the Subscriber/ErrorHandler.php
from 2.1.0 in 2.0.5? Should keep the Shopware 5.6.x compatibility and fix the issue.
EDIT: I made some tests and it seems to work.
Nach dem Letzten Update killt das Plugin den Shop.
Ich habe versucht neu zu installieren, caches zu löschen etc. Bringt alles nichts.
[12-Oct-2020 10:53:14 Europe/Berlin] PHP Fatal error: Uncaught Error: Class 'Sentry\ClientBuilder' not found in custom/plugins/OdSentry/vendor/sentry/sentry/src/functions.php:14 Stack trace:
0 custom/plugins/OdSentry/Subscriber/ErrorHandler.php(85): Sentry\init(Array)
1 custom/plugins/OdSentry/Subscriber/ErrorHandler.php(184): OdSentry\Subscriber\ErrorHandler->initSentry()
2 engine/Library/Enlight/Event/Handler/Default.php(87): OdSentry\Subscriber\ErrorHandler->onStartDispatch(Object(Enlight_Controller_EventArgs))
3 engine/Library/Enlight/Event/EventManager.php(214): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_EventArgs))
4 engine/Library/Enlight/Controller/Front.php(135): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_EventArgs))
5 engine/Shopware/Kernel.php(188): Enlight_Controller_Front->dispatch()
6 custom/plugins/OdSentry/vendor/sentry/sentry/src/functions.php on line 14