Skip to content

Commit 26e70b0

Browse files
committed
Merge branch 'master' into master-Lisio
2 parents 762f917 + 837c14c commit 26e70b0

File tree

10 files changed

+128
-14
lines changed

10 files changed

+128
-14
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# These are supported funding model platforms
22

33
open_collective: yiisoft
4+
github: [yiisoft]
5+
tidelift: "packagist/yiisoft/yii2-mongodb"

.github/SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Security Policy
2+
3+
Please use the [security issue form](https://www.yiiframework.com/security) to report to us any security issue you find in Yii.
4+
DO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help.
5+
6+
Please note that as a non-commerial OpenSource project we are not able to pay bounties at the moment.

.travis.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
language: php
22

3-
php:
4-
- 5.5
5-
- 5.6
6-
- 7.0
7-
- 7.1
8-
- 7.2
9-
- 7.3
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: "7.3"
7+
8+
- php: "7.2"
9+
10+
- php: "7.1"
11+
12+
- php: "7.0"
13+
14+
- php: "5.6"
15+
16+
- php: "5.5"
17+
dist: trusty
18+
19+
- php: "5.4"
20+
dist: trusty
1021

1122
services:
1223
- mongodb
@@ -41,3 +52,10 @@ before_script:
4152
4253
script:
4354
- vendor/bin/phpunit --verbose $PHPUNIT_FLAGS
55+
56+
after_script:
57+
- |
58+
if [ $TRAVIS_PHP_VERSION = '5.6' ]; then
59+
travis_retry wget https://scrutinizer-ci.com/ocular.phar
60+
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
61+
fi

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
Yii Framework 2 mongodb extension Change Log
22
============================================
33

4-
2.1.8 under development
5-
-----------------------
4+
2.1.10 under development
5+
------------------------
66

77
- no changes in this release.
88

99

10+
2.1.9 November 19, 2019
11+
-----------------------
12+
13+
- Bug #286: Fix `Collection::dropAllIndexes()` error when no indexes were dropped (samdark)
14+
15+
16+
2.1.8 October 08, 2019
17+
----------------------
18+
19+
- Bug #285: Fix `sessionWrite` callback fields (related to https://github.com/yiisoft/yii2/issues/17559 and https://github.com/yiisoft/yii2/pull/17188) (lubosdz)
20+
21+
1022
2.1.7 March 30, 2018
1123
--------------------
1224

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
1414

1515
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-mongodb/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
1616
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-mongodb/downloads.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
17-
[![Build Status](https://travis-ci.org/yiisoft/yii2-mongodb.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-mongodb)
17+
[![Build Status](https://travis-ci.com/yiisoft/yii2-mongodb.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-mongodb)
1818

1919

2020
Installation

docs/guide-ja/topics-migrations.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ yii mongodb-migrate
3030
# 最後に適用されたマイグレーションを取り消す
3131
yii mongodb-migrate/down
3232
```
33+
## 二つ以上の DB エンジンを使用するアプリケーションのための特殊な構成
34+
35+
アプリケーションが複数のデータベースを使う場合の例です。
36+
37+
- MySQL + MongoDB
38+
39+
マイグレーション・コマンドを実行すると、同時に MySQL と MongoDB の両方のマイグレーション・ファイルが対象として扱われます。これは両者が既定では同じフォルダを共有するためです。
40+
41+
**問題: MongoDB が MySQL のマイグレーション・ファイルを実行しようとし、MySQL が MongoDB のマイグレーション・ファイルを実行しようとする。**
42+
43+
この問題を回避するためには、`migrations` フォルダの下に `mongodb` という新しいフォルダを作って、コンソール・アプリケーションを次のようにセットアップすることが出来ます。
44+
45+
```php
46+
return [
47+
// ...
48+
'controllerMap' => [
49+
'mongodb-migrate' => [
50+
'class' => 'yii\mongodb\console\controllers\MigrateController',
51+
'migrationPath' => '@app/migrations/mongodb',
52+
],
53+
],
54+
];
55+
```

docs/guide/topics-migrations.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ yii mongodb-migrate
3030
# reverts the last applied migration
3131
yii mongodb-migrate/down
3232
```
33+
## Special configuration for an application that uses more than one DB engine
34+
35+
In case your application uses multiple databases, example:
36+
37+
- MySQL + MongoDB
38+
39+
If you run the migration commands, it will evaluate both MySQL and MongoDB migration files at the same time since both by default share the same folder.
40+
41+
**Problem: MongoDB will try to run MySQL's migration files and the other way around.**
42+
43+
In order to avoid that behavior, you can create a new folder called `mongodb` under your `migrations` folder, and then setup your console application like this:
44+
45+
```php
46+
return [
47+
// ...
48+
'controllerMap' => [
49+
'mongodb-migrate' => [
50+
'class' => 'yii\mongodb\console\controllers\MigrateController',
51+
'migrationPath' => '@app/migrations/mongodb',
52+
],
53+
],
54+
];
55+
```

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function dropIndex($columns)
206206
public function dropAllIndexes()
207207
{
208208
$result = $this->database->createCommand()->dropIndexes($this->name, '*');
209-
return $result['nIndexesWas'];
209+
return isset($result['nIndexesWas']) ? $result['nIndexesWas'] : 0;
210210
}
211211

212212
/**

src/Session.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class Session extends MultiFieldSession
5656
*/
5757
public $sessionCollection = 'session';
5858

59+
/**
60+
* @var array Session fields to be written into session table columns
61+
* @since 2.1.8
62+
*/
63+
protected $fields = [];
64+
5965

6066
/**
6167
* Initializes the Session component.
@@ -139,11 +145,35 @@ public function writeSession($id, $data)
139145
// exception must be caught in session write handler
140146
// http://us.php.net/manual/en/function.session-set-save-handler.php
141147
try {
148+
149+
// ensure backwards compatability, related to:
150+
// https://github.com/yiisoft/yii2/pull/17188
151+
// https://github.com/yiisoft/yii2/pull/17559
152+
if ($this->writeCallback && !$this->fields) {
153+
$this->fields = $this->composeFields();
154+
}
155+
156+
// ensure data consistency
157+
if (!isset($this->fields['data'])) {
158+
$this->fields['data'] = $data;
159+
} else {
160+
$_SESSION = $this->fields['data'];
161+
}
162+
163+
// ensure 'id' and 'expire' are never affected by [[writeCallback]]
164+
$this->fields = array_merge($this->fields, [
165+
'id' => $id,
166+
'expire' => time() + $this->getTimeout(),
167+
]);
168+
142169
$this->db->getCollection($this->sessionCollection)->update(
143170
['id' => $id],
144-
$this->composeFields($id, $data),
171+
$this->fields,
145172
['upsert' => true]
146173
);
174+
175+
$this->fields = [];
176+
147177
} catch (\Exception $e) {
148178
Yii::$app->errorHandler->handleException($e);
149179
return false;

tests/data/travis/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
This directory contains scripts for automated test runs via the [Travis CI](http://travis-ci.org) build service. They are used for the preparation of worker instances by setting up needed extensions and configuring database access.
1+
This directory contains scripts for automated test runs via the [Travis CI](http://travis-ci.com) build service. They are used for the preparation of worker instances by setting up needed extensions and configuring database access.
22

33
These scripts might be used to configure your own system for test runs. But since their primary purpose remains to support Travis in running the test cases, you would be best advised to stick to the setup notes in the tests themselves.
44

55
The scripts are:
66

77
- [`mongodb-setup.sh`](mongodb-setup.sh)
8-
Enables Mongo DB PHP extension
8+
Enables Mongo DB PHP extension

0 commit comments

Comments
 (0)