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

traversalDir() method stores in $this->dir globaly #8

Open
bahamasbahamas opened this issue Sep 11, 2019 · 0 comments
Open

traversalDir() method stores in $this->dir globaly #8

bahamasbahamas opened this issue Sep 11, 2019 · 0 comments

Comments

@bahamasbahamas
Copy link

bahamasbahamas commented Sep 11, 2019

Hey, if you call listSubdirs('/', true) in etcd/src/Client.php it works great but if you call listSubdirs('/', false) again you*ll get listSubdirs('/', true). I think the problem lives in traversalDir() method in etcd/src/Client.php. It stores in $this->dir globaly.

My quick fix would be:

    public function listSubdirs($key = '/', $recursive = false)
    {
        try {
            $data = $this->dirInfo($key, $recursive);
        } catch (EtcdException $e) {
            throw $e;
        }

        $iterator = new RecursiveArrayIterator($data);
	    
	//reset iterator array
        $this->dirs = [];

        return $this->traversalDir($iterator);
    }
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