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

MongoTripodConfig::getConnStr($storeName, $podName = null) always throws exception if podname is specified #45

Open
kiyanwang opened this issue Apr 1, 2015 · 3 comments
Labels

Comments

@kiyanwang
Copy link
Member

Since the Tripod changes were merged down, I needed to fix a couple of scripts I rely on for migrating comments from RL to Critic. I was trying to use the new MongoTripodConfig object to figure out how to get a handle to the Db object, the getConnStr method looked attractive because in principle I'd be able to get the connection string and create a mongo connection directly.

    public function getConnStr($storeName, $podName = null)
    {
        if (array_key_exists($storeName,$this->dbConfig))
        {
            if(!$podName)
            {
                return $this->getConnStrForDataSource($this->dbConfig[$storeName]['data_source']);
            }
            $pods = $this->getPods($storeName);
            if(array_key_exists($podName, $pods))
            {
                return $this->getConnStrForDataSource($pods[$podName]['data_source']);
            }
            throw new MongoTripodConfigException("Collection $podName does not exist for database $storeName");
        }
        else
        {
            throw new MongoTripodConfigException("Database $storeName does not exist in configuration");
        }
    }

The problem with this method is the array_key_exists check which will always return false, because $this->getPods($storeName) returns a simple array indexed by integer. So anytime you call getConnStr with a $podName set, it will throw a MongoTripodConfigException.

I'm also not sure if this method is actually used anywhere in the code, the fact that we have tripod-php in the lib directory and now also in the vendor directly is really confusing phpstorm.

@kiyanwang kiyanwang added the bug label Apr 1, 2015
@kiyanwang kiyanwang changed the title NMongoTripodConfig::getConnStr($storeName, $podName = null) always throws exception if podname is specified MongoTripodConfig::getConnStr($storeName, $podName = null) always throws exception if podname is specified Apr 1, 2015
@rsinger
Copy link
Member

rsinger commented Apr 1, 2015

There shouldn't be a tripod in /lib anymore: it's no longer installed via git submodules. Of course, there's no real way to have that affect historical instances. It will just need to be removed manually.

@kiyanwang
Copy link
Member Author

@rsinger thanks for that, just deleted it thats cleaned up a few things in phpstorm.

@scaleupcto
Copy link
Contributor

@rsinger @kiyanwang I assume your comments about lib and vendor apply to rl-app and not this repo - remember this is a public repo so any discussion should relate only to tripod and not apps that depend on it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants