spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Exception on campaign, when error_reporting is without "E_NOTICE" #191

Closed funkdoobiest closed 4 years ago

funkdoobiest commented 4 years ago

Hi,

following function is throwing an exception on our production system, where error reporting is like error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);

PHP 7.4.5 Mailcoach 2.11.5

Class "Models\Campaign":

public function getSegment(): Segment
    {
        $segmentClass = $this->segment_class ?? EverySubscriberSegment::class;

        try {
            $segmentClass = unserialize($segmentClass);
        } catch (\ErrorException $errorException) {
            // Do nothing, it was not a serialized string
        }

        if ($segmentClass instanceof Segment) {
            return $segmentClass->setCampaign($this);
        }

        return app($segmentClass)->setCampaign($this);
    }

The problem is the try catch on "unserialize". unserialize is throwing an "E_NOTICE" and returns FALSE. When error reporting is without "E_NOTICE" $segmentClass is FALSE and "app($segmentClass)" is throwing an exception.

I tried to use my own model class for campaign, but in this case (edit or save campaign) the function is not getting called on custom model.

freekmurze commented 4 years ago

What is the content of the E_NOTICE. Do you have a trace?

freekmurze commented 4 years ago

Closing due to inactivity.

funkdoobiest commented 4 years ago

There is no Exception with "error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);". That is ne problem. When setting "error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);" and you create a new campaign "$segmentClass" is null.

rubenvanassche commented 4 years ago

Hi @funkdoobiest, I've tried setting the error reporting to the levels you described, but no exception is thrown when creating a new campaign. I tried setting the error_reporting in config/app.php and the `AppServiceProvider. Where did you configure the error_reporting?

freekmurze commented 4 years ago

Closing due to inactivity.