!!!IMPORTANT!!!
The following upgrading instructions are cumulative. That is, if you want to upgrade from version A to version C and there is version B between A and C, you need to following the instructions for both A and B.
-
yii\mongodb\Session
now respects the 'session.use_strict_mode' ini directive. In case you use a customSession
class and have overwritten theSession::openSession()
and/orSession::writeSession()
functions changes might be required:- When in strict mode the
openSession()
function should check if the requested session id exists (and mark it for forced regeneration if not). For example, theyii\mongodb\Session
does this at the beginning of the function as follows:if ($this->getUseStrictMode()) { $id = $this->getId(); $collection = $this->db->getCollection($this->sessionCollection); $condition = [ 'id' => $id, 'expire' => ['$gt' => time()], ]; if (!$collection->documentExists($condition)) { //This session id does not exist, mark it for forced regeneration $this->_forceRegenerateId = $id; } } // ... normal function continues ...
- When in strict mode the
writeSession()
function should ignore writing the session under the old id. For example, theyii\mongodb\Session
does this at the beginning of the function as follows:if ($this->getUseStrictMode() && $id === $this->_forceRegenerateId) { //Ignore write when forceRegenerate is active for this id return true; } // ... normal function continues ...
Note: In case your custom functions call their
parent
functions, there are probably no changes needed to your code if those parents implement theuseStrictMode
checks.Warning: in case
openSession()
and/orwriteSession()
functions do not implement theuseStrictMode
code the session could be stored under the forced id without warning even ifuseStrictMode
is enabled. - When in strict mode the
-
PHP mongodb extension is now used instead of mongo. Make sure you have 'mongodb' extension at your environment. Some features based on old driver may become unavailable. In particular: fields
Connection::mongoClient
,Database::mongoDb
andCollection::mongoCollection
are no longer exist. Old driver type classes such as\MongoId
,\MongoCode
,\MongoDate
and so on, are no longer returned or recognized. Make sure you are using their analogs from\MongoDB\BSON\*
namespace. -
MongoDB server versions < 3.0 are no longer supported. Make sure you are running MongoDB server >= 3.0
-
The signature of the following
\yii\mongodb\Collection
methods has been changed:aggregate()
,distinct()
,find()
,findOne()
,findAndModify()
. Make sure you invoke those methods correctly. In case you are extending\yii\mongodb\Collection
, you should check, if overridden methods match parent declaration. -
Command and query composition methods at
\yii\mongodb\Collection
, such asbuildCondition()
,ensureMongoId()
and so on, have been removed. Use\yii\mongodb\QueryBuilder
methods instead. -
Method
Database::executeCommand()
has been removed. UseCommand
class for plain MongoDB command execution. You may create command with database scope usingDatabase::createCommand()
method. -
Method
Collection::fullTextSearch()
has been removed. Use$text
query condition instead. -
Method
Collection::getName()
has been removed. UseCollection::name
in order to get collection self name. -
For GridFS
yii\mongodb\file\Download
is returned instead of\MongoGridFSFile
for the query result set. -
Cursor composed via
yii\mongodb\file\Collection::find()
now returns result in the same format asyii\mongodb\file\Query::one()
. If you wish to perform file manipulations on returned row you should usefile
key instead of direct method invocations.
- MongoDB PHP extension min version raised up to 1.5.0. You should upgrade your environment in case you are using older version.
- MongoDB PHP extension min version raised up to 1.4.0. You should upgrade your environment in case you are using older version.