Skip to content

V5 #3041

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

Closed
wants to merge 10 commits into from
Closed

V5 #3041

wants to merge 10 commits into from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jul 11, 2024

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

@github-actions github-actions bot added the docs label Jul 11, 2024
{
$connection = $this->getMongoDBConnection();

$collection = $this->app['config']['session.table'];

Check failure

Code scanning / PHPStan

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app. Error

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.

$collection = $this->app['config']['session.table'];

$database = (string) $connection->getMongoDB();

Check failure

Code scanning / PHPStan

Call to method getMongoDB() on an unknown class MongoDB\Laravel\Session\Connection. Error

Call to method getMongoDB() on an unknown class MongoDB\Laravel\Session\Connection.

$database = (string) $connection->getMongoDB();

$handler = new MongoDbSessionHandler($connection->getMongoClient(), $this->getMongoDBOptions($database, $collection));

Check failure

Code scanning / PHPStan

Call to method getMongoClient() on an unknown class MongoDB\Laravel\Session\Connection. Error

Call to method getMongoClient() on an unknown class MongoDB\Laravel\Session\Connection.
*
* @return Connection
*/
protected function getMongoDBConnection()

Check failure

Code scanning / PHPStan

Method MongoDB\Laravel\Session\SessionManager::getMongoDBConnection() has invalid return type MongoDB\Laravel\Session\Connection. Error

Method MongoDB\Laravel\Session\SessionManager::getMongoDBConnection() has invalid return type MongoDB\Laravel\Session\Connection.
*/
protected function getMongoDBConnection()
{
$connection = $this->app['config']['session.connection'];

Check failure

Code scanning / PHPStan

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app. Error

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.
// The default connection may still be mysql, we need to verify if this connection
// is using the mongodb driver.
if (is_null($connection)) {
$default = $this->app['db']->getDefaultConnection();

Check failure

Code scanning / PHPStan

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app. Error

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.
if (is_null($connection)) {
$default = $this->app['db']->getDefaultConnection();

$connections = $this->app['config']['database.connections'];

Check failure

Code scanning / PHPStan

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app. Error

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.
}
}

return $this->app['db']->connection($connection);

Check failure

Code scanning / PHPStan

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app. Error

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.
Query Builder return stdClass: https://github.com/laravel/framework/blob/213a370b703592587bafcd52d38a0ad772ff7442/src/Illuminate/Database/Connection.php#L118C16-L118C25
Alias id for _id everywhere
Don't expose _id field:
No _id attribute in Eloquent.
Deprecate reading and writing _id attribute.
Always convert datetime to UTCDateTime: https://github.com/laravel/framework/blob/213a370b703592587bafcd52d38a0ad772ff7442/src/Illuminate/Database/Connection.php#L733-L734
Timezone : using Carbon instead of system timezone.
*
* @var string
*/
protected $primaryKey = '_id';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary key can keep the default value id, which is converted to _id by the query builder.

@@ -451,7 +456,7 @@ public function toMql(): array
}

// Fix for legacy support, converts the results to arrays instead of objects.
$options['typeMap'] = ['root' => 'array', 'document' => 'array'];
$options['typeMap'] = ['root' => 'object', 'document' => 'array'];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major breaking change to meet Laravel's behavior: the query builder returns a stdClass object.

Comment on lines 9 to 10
/** @deprecated Use {@see DatabaseFailedJobProvider} */
class MongoFailedJobProvider extends DatabaseFailedJobProvider
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is no longer necessary as the Laravel class works out of the box thanks to the change of id field, automatic transformation of dates, and results returned as objects.

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

Successfully merging this pull request may close these issues.

1 participant