mvdbos / php-spider

A configurable and extensible PHP web spider
MIT License
1.33k stars 233 forks source link

"EventDispatcher::dispatch() must be an object, string given" #66

Closed spekulatius closed 4 years ago

spekulatius commented 4 years ago

Hello @mvdbos,

I'm about to use php-spider as part of a Laravel 7 project and got this error when starting a crawl:

Argument 1 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an object, string given, called in /var/www/dev.project.com/vendor/vdb/php-spider/src/VDB/Spider/QueueManager/InMemoryQueueManager.php on line 88

I started researching it more and I guessed that it comes from a breaking change introduced with the upgrade of symfony/event-dispatcher from v4.4.5 to v5.0.5.

I've checked a bit more and found out that my version of php-spider is actually reverted from v0.4.2 down to v0.2. It's because v0.2 didn't require event-dispatcher and was therefore matching my set of requirements.

I've looked closer at the error and found that switching the parameters on line 87 & 88 in the InMemoryQueueManager-class fixed it. I've prepared a PR and started writing this issue as I've found the old issue about this: https://github.com/mvdbos/php-spider/issues/61 haha. I could have solved it quicker :)

It would be great if you could let me know if the PR works or you or needs further tweaks.

Just in case - Interesting versions / packages:

PHP 7.2.24

laravel/framework                     v7.2.2     
guzzle/guzzle                         v3.8.1       
symfony/event-dispatcher              v5.0.5            
symfony/event-dispatcher-contracts    v2.0.1     
vdb/php-spider                        v0.2              
vdb/uri                               v0.2              

Cheers, Peter

errorteam10 commented 4 years ago

I'm about to use this in a laravel project also. Could you share in more detail the fixes?

On Wed, Mar 25, 2020 at 3:30 PM Peter Thaleikis notifications@github.com wrote:

Hello @mvdbos https://github.com/mvdbos,

I'm about to use php-spider as part of a Laravel 7 project and got this error when starting a crawl:

Argument 1 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an object, string given, called in /var/www/ dev.project.com/vendor/vdb/php-spider/src/VDB/Spider/QueueManager/InMemoryQueueManager.php on line 88

I started researching it more and I guessed that it comes from a breaking change introduced with the upgrade of symfony/event-dispatcher from v4.4.5 to v5.0.5.

I've checked a bit more and found out that my version of php-spider is actually reverted from v0.4.2 down to v0.2. It's because v0.2 didn't require event-dispatcher and was therefore matching my set of requirements.

I've looked closer at the error and found that switching the parameters on line 87 & 88 in the InMemoryQueueManager-class fixed it. I've prepared a PR and started writing this issue as I've found the old issue about this:

61 https://github.com/mvdbos/php-spider/issues/61 haha. I could have

solved it quicker :)

It would be great if you could let me know if the PR works or you or needs further tweaks.

Just in case - Interesting versions / packages:

PHP 7.2.24

laravel/framework v7.2.2 guzzle/guzzle v3.8.1 symfony/event-dispatcher v5.0.5 symfony/event-dispatcher-contracts v2.0.1 vdb/php-spider v0.2 vdb/uri v0.2

Cheers, Peter

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mvdbos/php-spider/issues/66, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEEOJ3GKKN76D5VUHHZCN3RJJZZDANCNFSM4LTYR4KA .

spekulatius commented 4 years ago

Hello @errorteam10,

It's only an issue when using Laravel 7. With Laravel 6 there aren't any problems for me. The fix for Laravel 7-based projects is in work. You can see the details here in the PR https://github.com/mvdbos/php-spider/pull/67. But I wouldn't use this at this point as there are more changes to come. Keep an eye on the PR, if interested.

Cheers, Peter

spekulatius commented 4 years ago

Hello @errorteam10,

would be awesome if you could verify if it works for you now :)

Cheers, Peter