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

MongoDB class existence check is out of date (with PHP7.0) #2116

Open
GodStorm91 opened this issue May 10, 2019 · 4 comments
Open

MongoDB class existence check is out of date (with PHP7.0) #2116

GodStorm91 opened this issue May 10, 2019 · 4 comments

Comments

@GodStorm91
Copy link

PHP MongoDB Driver has been updated in 2016, the old client class Mongo is deprecated.

https://derickrethans.nl/new-drivers.html

But we still have this check in our core MongoDB class. Should we change it

		if ( ! class_exists('Mongo'))
		{
			throw new \Mongo_DbException("The MongoDB PECL extension has not been installed or enabled");
		}

The new check should be

		if ( ! class_exists('Mongo') && ! class_exists('MongoDB\Client'))
		{
			throw new \Mongo_DbException("The MongoDB PECL extension has not been installed or enabled");
		}

By the way, I think in the near future we should remove the ! class_exists('Mongo') check too.

@WanWizard
Copy link
Member

That is assuming the new MongoDB\Client class has exactly the same API als the old Mongo class. Is that the case? If not, the entire abstraction layer has to be rewritten, in which case you'd probably be better of using an external Mongo library.

@GodStorm91
Copy link
Author

Thank you for your reply.
Currently we have to override the core class and override some methods to match with the new MongoDB Client.
Actually some methods in the driver have been changed, and I think the best solution is to write a new Abstraction Driver or using an external library.

@WanWizard
Copy link
Member

Is your class override complete? i.e. do all methods available work with the new MongoDB Client, or did you just override the methods you use?

I am willing to try and find the time to add the abstraction, but I am not a Mongo user, if you have complete code and willing to donate it?

@GodStorm91
Copy link
Author

currently we only override only some methods we used.
But I think I will check remaining methods whether they need to be changed or not.
I will share my complete code after I finish :)

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

2 participants