Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored Apr 13, 2024
2 parents 848ddf9 + a733e8a commit 43f8f50
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ jobs:
uses: niden/actions-memcached@v7

- name: Install dependencies.
if: matrix.php != '8.4'
run: composer update $DEFAULT_COMPOSER_FLAGS

- name: Install dependencies with PHP 8.4.
if: matrix.php == '8.4'
run: composer update $DEFAULT_COMPOSER_FLAGS --ignore-platform-reqs

- name: Run tests with PHPUnit and generate coverage.
if: matrix.php == '7.4'
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --coverage-clover=coverage.xml --colors=always
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci-mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ jobs:
run: composer self-update

- name: Install dependencies with composer
if: matrix.php != '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with PHP 8.4.
if: matrix.php == '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ignore-platform-reqs --ansi

- name: Run MSSQL tests with PHPUnit and generate coverage.
run: vendor/bin/phpunit --group mssql --coverage-clover=coverage.xml --colors=always

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ jobs:
php-version: ${{ matrix.php }}
tools: composer:v2, pecl

- name: Install dependencies with composer.
- name: Install dependencies with composer
if: matrix.php != '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with PHP 8.4.
if: matrix.php == '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ignore-platform-reqs --ansi

- name: Run MySQL tests with PHPUnit and generate coverage.
run: vendor/bin/phpunit --group mysql --coverage-clover=coverage.xml --colors=always

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ jobs:
- name: Update composer.
run: composer self-update

- name: Install dependencies with composer.
- name: Install dependencies with composer
if: matrix.php != '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with PHP 8.4.
if: matrix.php == '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ignore-platform-reqs --ansi

- name: Run Pgsql tests with PHPUnit and generate coverage.
run: vendor/bin/phpunit --group pgsql --coverage-clover=coverage.xml --colors=always

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ jobs:
- name: Update composer.
run: composer self-update

- name: Install dependencies with composer.
- name: Install dependencies with composer
if: matrix.php != '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with PHP 8.4.
if: matrix.php == '8.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ignore-platform-reqs --ansi

- name: Run SQLite tests with PHPUnit and generate coverage.
run: vendor/bin/phpunit --group sqlite --coverage-clover=coverage.xml --colors=always

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ and a [Definitive Guide Mirror](http://stuff.cebe.cc/yii2docs/) which is updated
- For Yii 1.1 users, there is [Upgrading from Yii 1.1](https://www.yiiframework.com/doc/guide/2.0/en/intro-upgrade-from-v1)
to get an idea of what has changed in 2.0.

Versions & PHP compatibility
----------------------------

| Yii2 Version | PHP version | Development status | EOL ¹ |
|--------------|----------------|-----------------------------------|----------------------------------------------------------------|
| <= 2.0.49.* | >= 5.4, <= 8.3 | security fixes only | 23 Nov 2026 ³ |
| >= 2.0.50 | >= 7.3, <= 8.4 | bug fixes and security fixes only | bugfixes till 23 Nov 2026 ³, security fixes till 21 Nov 2027 ⁴ |
| >= 2.2.0 ² | >= 8.1 | active development | |

¹ All mentioned dates may be subject to change and no rights can be derived from them.
² Note: Yii 2.1 was [skipped](https://github.com/yiisoft/yii2/discussions/19831#discussioncomment-5858046), [Yii 2.2](https://github.com/yiisoft/yii2/tree/2.2) has not yet been released.
³ [PHP 8.3 EOL date](https://www.php.net/supported-versions.php).
[Expected PHP 8.4 EOL date](https://wiki.php.net/todo/php84).

Community
---------

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"ext-ctype": "*",
"lib-pcre": "*",
"yiisoft/yii2-composer": "~2.0.4",
"ezyang/htmlpurifier": "^4.6",
"ezyang/htmlpurifier": "^4.17",
"cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0",
"bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"bower-asset/inputmask": "^5.0.8 ",
Expand Down
2 changes: 1 addition & 1 deletion docs/internals/git-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ review your suggestion, and provide appropriate feedback along the way.
### 2. Pull the latest code from the main Yii branch

```
git pull upstream
git pull upstream master
```

You should start at this point for every new contribution to make sure you are working on the latest code.
Expand Down
4 changes: 3 additions & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ Yii Framework 2 Change Log
- Enh #20042: Add empty array check to `ActiveQueryTrait::findWith()` (renkas)
- Enh #20032: Added `yii\helpers\BaseStringHelper::mask()` method for string masking with multibyte support (salehhashemi1992)
- Enh #20034: Added `yii\helpers\BaseStringHelper::findBetween()` to retrieve a substring that lies between two strings (salehhashemi1992)
- Bug #20083: Fix deprecated warning implicit conversion from float (skepticspriggan)
- Enh #20087: Add custom attributes to script tags (skepticspriggan)
- Enh #20121: Added `yiisoft/yii2-coding-standards` to composer `require-dev` and lint code to comply with PSR12 (razvanphp)
- New: Added `yii\caching\CallbackDependency` to allow using a callback to determine if a cache dependency is still valid (laxity7)
- Enh #20134: Raise minimum `PHP` version to `7.3` (@terabytesoftw)

- Bug #20141: Update `ezyang/htmlpurifier` dependency to version `4.17` (@terabytesoftw)

2.0.49.2 October 12, 2023
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"ext-ctype": "*",
"lib-pcre": "*",
"yiisoft/yii2-composer": "~2.0.4",
"ezyang/htmlpurifier": "^4.6",
"ezyang/htmlpurifier": "^4.17",
"cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0",
"bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"bower-asset/inputmask": "^5.0.8 ",
Expand Down
1 change: 1 addition & 0 deletions framework/db/BaseActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ public function getDirtyAttributes($names = null)
* @param array|null $attributeNames list of attribute names that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* @return bool whether the saving succeeded (i.e. no validation errors occurred).
* @throws Exception in case update or insert failed.
*/
public function save($runValidation = true, $attributeNames = null)
{
Expand Down
5 changes: 5 additions & 0 deletions framework/helpers/BaseHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ public static function style($content, $options = [])
*/
public static function script($content, $options = [])
{
$view = Yii::$app->getView();
if ($view instanceof \yii\web\View && !empty($view->scriptOptions)) {
$options = array_merge($view->scriptOptions, $options);
}

return static::tag('script', $content, $options);
}

Expand Down
2 changes: 1 addition & 1 deletion framework/i18n/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ public function asDuration($value, $implodeString = ', ', $negativeSign = '-')
} elseif (is_numeric($value)) {
$isNegative = $value < 0;
$zeroDateTime = (new DateTime())->setTimestamp(0);
$valueDateTime = (new DateTime())->setTimestamp(abs($value));
$valueDateTime = (new DateTime())->setTimestamp(abs((int) $value));
$interval = $valueDateTime->diff($zeroDateTime);
} elseif (strncmp($value, 'P-', 2) === 0) {
$interval = new DateInterval('P' . substr($value, 2));
Expand Down
5 changes: 5 additions & 0 deletions framework/web/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class View extends \yii\base\View
* @see registerJsFile()
*/
public $jsFiles = [];
/**
* @since 2.0.50
* @var array the script tag options.
*/
public $scriptOptions = [];

private $_assetManager;

Expand Down
15 changes: 15 additions & 0 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ public function testScript()
$this->assertEquals("<script type=\"text/js\">{$content}</script>", Html::script($content, ['type' => 'text/js']));
}

public function testScriptCustomAttribute()
{
$nonce = Yii::$app->security->generateRandomString();
$this->mockApplication([
'components' => [
'view' => [
'class' => 'yii\web\View',
'scriptOptions' => ['nonce' => $nonce],
],
],
]);
$content = 'a <>';
$this->assertEquals("<script nonce=\"{$nonce}\">{$content}</script>", Html::script($content));
}

public function testCssFile()
{
$this->assertEquals('<link href="http://example.com" rel="stylesheet">', Html::cssFile('http://example.com'));
Expand Down
1 change: 1 addition & 0 deletions tests/framework/i18n/FormatterDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ public function testAsDuration()
// other options
$this->assertSame('minus 244 seconds', $this->formatter->asDuration($interval_244_seconds, ' and ', 'minus '));
$this->assertSame('minus 4 minutes and 4 seconds', $this->formatter->asDuration(-244, ' and ', 'minus '));
$this->assertSame('1 second', $this->formatter->asDuration(1.5));

// Pass a inverted DateInterval string
$this->assertSame('-1 year, 2 months, 10 days, 2 hours, 30 minutes', $this->formatter->asDuration('2008-05-11T15:30:00Z/2007-03-01T13:00:00Z'));
Expand Down

0 comments on commit 43f8f50

Please sign in to comment.