Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
GromNaN wants to merge 10 commits into mongodb:4.8 from GromNaN:_id
Closed

V5 #3041

GromNaN wants to merge 10 commits into mongodb:4.8 from GromNaN:_id

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Jul 11, 2024
edited
Loading

Checklist

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

masterbater reacted with rocket emoji
{
public function __construct($app)
{
$this->app = $app;

Check failure

Code scanning / PHPStan

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

Access to an undefined property MongoDB\Laravel\Session\SessionManager::$app.
{
$connection = $this->getMongoDBConnection();

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

Check failure

Code scanning / PHPStan

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

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.

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.

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.

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.

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.

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.

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.

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.


// 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.

masterbater reacted with hooray emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Awaiting requested review from Copilot Copilot will automatically review once the pull request is marked ready for review

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /