Skip to content

TypeError: array_key_exists() expects parameter 2 to be array, null given #833

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

Closed
dhanabalarumugam opened this issue Apr 30, 2019 · 4 comments · Fixed by #836
Closed

TypeError: array_key_exists() expects parameter 2 to be array, null given #833

dhanabalarumugam opened this issue Apr 30, 2019 · 4 comments · Fixed by #836
Labels

Comments

@dhanabalarumugam
Copy link

TypeError: array_key_exists() expects parameter 2 to be array, null given

/vendor/enqueue/amqp-lib/AmqpSubscriptionConsumer.php:98

@Steveb-p
Copy link
Contributor

This?

if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) {

Please confirm which version on php-enqueue you're using. You can run composer info enqueue/* to get that information without looking through composer.lock file.

@Steveb-p Steveb-p changed the title ypeError: array_key_exists() expects parameter 2 to be array, null given TypeError: array_key_exists() expects parameter 2 to be array, null given Apr 30, 2019
@dhanabalarumugam
Copy link
Author

This is what I'm getting
enqueue/amqp-lib 0.9.8 Message Queue Amqp Transport
enqueue/amqp-tools 0.9.8 Message Queue Amqp Tools
enqueue/dsn 0.9.2 Parse DSN

@Steveb-p
Copy link
Contributor

Steveb-p commented May 2, 2019

I've looked through the code and yeah, it seems that this particular array was simply not initialized :/

On your local copy you can simply initialize it - in constructor or as part of property declaration - and see if it helps and the library works. I'm not familiar with this code so I can't say for sure for myself.

    public function __construct(AmqpContext $context, bool $heartbeatOnTick)
    {
        $this->subscribers = []; // <--- Here
        $this->context = $context;
        $this->heartbeatOnTick = $heartbeatOnTick;
    }

If it's all that is required and it works properly after that, I'll provide a PR for you.

@Steveb-p Steveb-p added the bug label May 2, 2019
@dhanabalarumugam
Copy link
Author

dhanabalarumugam commented May 3, 2019

Thank you

Steveb-p added a commit to Steveb-p/enqueue-dev that referenced this issue May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants