-
Notifications
You must be signed in to change notification settings - Fork 125
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
Parameter 1 to MongoCollection::insert() expected to be a reference, value given #107
Comments
Unfortunately,
I had the choice:
The original intent of the driver was to have the argument by-reference so that an auto-generated ID could be added. Thus, I settled for option #2, knowing that people can either handle that specific warning in an error handler or ignore it. On the other hand, having code break because you were expecting an TL;DR: I wouldn't recommend it. |
OK,I solved it. If we need insert or save data to db, we add the reference to the first param. if (PHP_VERSION_ID > 70000 && in_array($method, ['insert', 'batchInsert', 'save'])) {
$saveData = array_shift($param);
$saveParams = array_shift($param);
if (NULL==$saveParams) {
$saveParams = [];
}
$re = call_user_func_array([$collection, $method], [&$saveData, $saveParams]);
} else {
$re = call_user_func_array([$collection, $method], $param);
} |
@glowdan can you please elaborate more ? Where did you add this patch ? I'm using https://github.com/jenssegers/laravel-mongodb with Laravel 4.2.x along with PHP7.0, and this is the only step I'm struggling with. |
@Ardakilic Check this out: LearningLocker/learninglocker#893 |
Thanks @rhclayto , will look right away! |
alcaeus/mongo-php-adapter is a dropin replacement for php mongo extension for recent version of php. it allow to use ext-mongo like ext-mongodb. We use it to use phlask with php7, however, there are annoying notices when running because lock->insert and col->save now take arguments by reference rather than by value. alcaeus/mongo-php-adapter#107 This should silence the notices.
Hi,
When we upgrade our website from php5.5 to php7.0.6. We got some warning like this:
And I saw the same question occurs on wordpress. May I remove the "&" in "alcaeus/mongo-php-adapter/lib/Mongo/MongoCollection.php::insert on line 277"?
The text was updated successfully, but these errors were encountered: