Skip to content
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

Non-strict array_search causes issues in CompositeDisposable (and likely other places) #107

Closed
mbonneau opened this issue Dec 28, 2016 · 0 comments

Comments

@mbonneau
Copy link
Member

There is non-strict array searching in side the CompositeDisposable that cause unexpected/incorrect results in some situations:

Reproducing code:

<?php

use React\EventLoop\Factory;
use Rx\Observable;
use Rx\Observer\CallbackObserver;
use Rx\Testing\TestScheduler;

require_once __DIR__ . '/vendor/autoload.php';

$loop = Factory::create();

$scheduler = new TestScheduler();

$o = Observable::interval(500)
    ->merge(Observable::range(1,3))
    ->take(5)
    ->subscribe(new CallbackObserver(function ($x) {
        echo "Next: $x\n";
    }, function (Exception $exception) {
        echo "Err\n";
    }, function () {
        echo "Complete\n";
    }), $scheduler);

$scheduler->start();

Expected output:

Next: 1
Next: 2
Next: 3
Next: 0
Next: 1
Complete

Actual output:

Next: 1
Next: 2
Next: 3

This is caused by CompositeDisposable finding the incorrect Disposable here:

$key = array_search($disposable, $this->disposables);

This is can be corrected by enforcing strict comparison (passing true as the third argument to array_search)

PR on the way.

mbonneau added a commit to mbonneau/RxPHP that referenced this issue Dec 28, 2016
davidwdan added a commit that referenced this issue Dec 28, 2016
Fix non-strict search in CompositeDisposable Fixes #107
davidwdan pushed a commit to davidwdan/RxPHP that referenced this issue Dec 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant