Skip to content

Commit

Permalink
Merge branch 'release/3.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 21, 2019
2 parents 1ce18a3 + 4e33230 commit 0d7c54f
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 52 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Release Notes for Craft CMS 3.x

## 3.1.3 - 2019-01-21

### Added
- Added the `|json_decode` Twig filter. ([#3678](https://github.com/craftcms/cms/pull/3678))

### Fixed
- Fixed an error that occurred when updating to Craft 3.1 if a plugin or module was calling any soft-deletable records’ `find()` methods.
- Fixed an error that occurred when updating from Craft 2 to Craft 3.1 if there were any RichText fields. ([#3677](https://github.com/craftcms/cms/issues/3677))
- Fixed a bug where it was possible to create duplicate tags by searching for and selecting the same tag name twice in the same Tags field. ([#3676](https://github.com/craftcms/cms/issues/3676))
- Fixed a bug where system messages were getting sent with the message keys (e.g. “forgot_password_subject” and “forgot_password_body”) if Craft didn’t provide a default message translation for the site language, and the message hadn’t been translated for the user’s preferred language. ([#3673](https://github.com/craftcms/cms/issues/3673))
- Fixed a bug where `craft\web\Request::getIsLivePreview()` was returning `false` on Live Preview requests when called from an `yii\base\Controller::EVENT_BEFORE_ACTION` event handler. ([#3680](https://github.com/craftcms/cms/issues/3680))

## 3.1.2.2 - 2019-01-19

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "craftcms/cms",
"description": "Craft CMS",
"version": "3.1.2.2",
"version": "3.1.3",
"keywords": [
"cms",
"craftcms",
Expand Down
8 changes: 8 additions & 0 deletions docs/dev/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ Returns an array containing only the values that are also in a passed-in array.

Like Twig’s core [json_encode](https://twig.symfony.com/doc/2.x/filters/json_encode.html) filter, but if the `options` argument isn’t set, it will default to `JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT` if the response content type is either `text/html` or `application/xhtml+xml`.

## `json_decode`

JSON-decodes a string into an array by passing it through <api:yii\helpers\Json::decode()>.

```twig
{% set arr = '[1, 2, 3]'|json_decode %}
```

## `kebab`

Returns a string formatted in “kebab-case”.
Expand Down
4 changes: 2 additions & 2 deletions src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
return [
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '3.1.2.2',
'schemaVersion' => '3.1.21',
'version' => '3.1.3',
'schemaVersion' => '3.1.22',
'minVersionRequired' => '2.6.2788',
'basePath' => dirname(__DIR__), // Defines the @app alias
'runtimePath' => '@storage/runtime', // Defines the @runtime alias
Expand Down
5 changes: 2 additions & 3 deletions src/controllers/LivePreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class LivePreviewController extends Controller
*/
public function beforeAction($action)
{
// Don't enable CSRF validation for live-preview/preview requests
// Mark this as a Live Preview request
if ($action->id === 'preview') {
$this->enableCsrfValidation = false;
Craft::$app->getRequest()->setIsLivePreview(true);
}

return parent::beforeAction($action);
Expand Down Expand Up @@ -101,7 +101,6 @@ public function actionPreview(string $previewAction, int $userId)
->add('Access-Control-Allow-Origin', Craft::$app->getRequest()->getOrigin())
->add('Access-Control-Allow-Credentials', 'true');

Craft::$app->getRequest()->setIsLivePreview(true);
return Craft::$app->runAction($previewAction);
}
}
11 changes: 8 additions & 3 deletions src/controllers/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ public function actionSearchForTags(): Response
$tags = Tag::find()
->groupId($tagGroupId)
->title(Db::escapeParam($search) . '*')
->where(['not', ['elements.id' => $excludeIds]])
->all();

$return = [];
$exactMatches = [];
$excludes = [];
$tagTitleLengths = [];
$exactMatch = false;

Expand All @@ -201,9 +201,12 @@ public function actionSearchForTags(): Response
}

foreach ($tags as $tag) {
$exclude = in_array($tag->id, $excludeIds, false);

$return[] = [
'id' => $tag->id,
'title' => $tag->title
'title' => $tag->title,
'exclude' => $exclude,
];

$tagTitleLengths[] = StringHelper::length($tag->title);
Expand All @@ -220,9 +223,11 @@ public function actionSearchForTags(): Response
} else {
$exactMatches[] = 0;
}

$excludes[] = $exclude ? 1 : 0;
}

array_multisort($exactMatches, SORT_DESC, $tagTitleLengths, $return);
array_multisort($excludes, SORT_ASC, $exactMatches, SORT_DESC, $tagTitleLengths, $return);

return $this->asJson([
'tags' => $return,
Expand Down
11 changes: 10 additions & 1 deletion src/db/SoftDeleteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace craft\db;

use Craft;
use craft\helpers\Db;
use yii\db\ActiveQuery;
use yii2tech\ar\softdelete\SoftDeleteBehavior;
Expand Down Expand Up @@ -80,7 +81,15 @@ trait SoftDeleteTrait
*/
public static function find()
{
return parent::find()->where(['dateDeleted' => null]);
$query = parent::find();

// todo: remove schema version condition after next beakpoint
$schemaVersion = Craft::$app->getProjectConfig()->get('system.schemaVersion');
if (version_compare($schemaVersion, '3.1.19', '>=')) {
$query->where(['dateDeleted' => null]);
}

return $query;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/I18N.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ public function translate($category, $message, $params, $language)
{
$translation = parent::translate($category, $message, $params, $language);

// If $message is a key and came back identical to the input, translate it into the source language
if ($translation === $message) {
$messageSource = $this->getMessageSource($category);
if ($messageSource->sourceLanguage !== $language) {
$translation = parent::translate($category, $message, $params, $messageSource->sourceLanguage);
}
}

if ($this->_shouldAddTranslationDebugOutput()) {
switch ($category) {
case 'site':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function safeUp()
$fields = (new Query())
->select(['id', 'settings'])
->from([Table::FIELDS])
->where(['type' => 'craft\\redactor\\Fields'])
->where(['type' => 'craft\\redactor\\Field'])
->all($this->db);

foreach ($fields as $field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use craft\helpers\Json;

/**
* m170414_162429_rich_text_config_setting migration.
* m190121_120000_rich_text_config_setting migration.
*/
class m170414_162429_rich_text_config_setting extends Migration
class m190121_120000_rich_text_config_setting extends Migration
{
/**
* @inheritdoc
Expand All @@ -28,6 +28,9 @@ public function safeUp()
// configFile => redactorConfig
foreach ($fields as $field) {
$settings = Json::decode($field['settings']);
if (isset($settings['redactorConfig'])) {
continue;
}
$settings['redactorConfig'] = ArrayHelper::remove($settings, 'configFile');
$this->update(Table::FIELDS, [
'settings' => Json::encode($settings)
Expand All @@ -42,7 +45,7 @@ public function safeUp()
*/
public function safeDown()
{
echo "m170414_162429_rich_text_config_setting cannot be reverted.\n";
echo "m190121_120000_rich_text_config_setting cannot be reverted.\n";
return false;
}
}
17 changes: 7 additions & 10 deletions src/migrations/m190218_143000_element_index_settings_uid.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function safeUp()
->pairs();

$this->_elementData[Asset::class] = (new Query())
->select(['folders.id folderId', 'volumes.uid volumeUid'])
->from([Table::VOLUMES . ' volumes'])
->innerJoin([Table::VOLUMEFOLDERS . ' folders'], '[[volumes.id]] = [[folders.volumeId]]')
->select(['id', 'uid'])
->from([Table::VOLUMEFOLDERS])
->where(['parentId' => null])
->pairs();

$rows = (new Query())
Expand Down Expand Up @@ -113,16 +113,13 @@ private function _normalizeSourceKey(string $sourceKey, $elementClass): string
return $sourceKey;
}

$parts = explode(':', $sourceKey);
$parts = explode(':', $sourceKey, 2);
$id = $parts[1];

if ($elementClass === Asset::class) {
$replace = 'volume';
} else {
$replace = $this->_elements[$elementClass];
if (!isset($this->_elementData[$elementClass][$id])) {
return $sourceKey;
}


return array_key_exists($id, $this->_elementData[$elementClass]) ? $replace.':'.$this->_elementData[$elementClass][$id] : $sourceKey;
return $this->_elements[$elementClass] . ':' . $this->_elementData[$elementClass][$id];
}
}
2 changes: 1 addition & 1 deletion src/translations/de/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@
'Sources' => 'Quellen',
'Square' => 'Quadrat',
'Square SVG file recommended. The logo will be displayed at {size} by {size}.' => 'Quadratische SVG-Datei empfohlen Das Logo wird in der Größe {size} x {size} angezeigt.',
'Stack Trace' => 'Stapelspur',
'Stack Trace' => 'Stack Trace',
'Staff Picks' => 'Auswahl unserer Mitarbeiter',
'Status' => 'Status',
'Status updated, with some failures due to validation errors.' => 'Status wurde – aufgrund von Validierungsfehlern nicht vollständig erfolgreich – aktualisiert.',
Expand Down
6 changes: 3 additions & 3 deletions src/translations/ja/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@
'five' => '5',
'folders' => 'フォルダ',
'folders and files' => 'フォルダとファイル',
'forgot_password_body' => 'こんにちわ、{{user.friendlyName}} さん、{{siteName}}を再設定するには、このリンクをクリックしてください:&lt;{{link}}&gt;このメールに心当たりがない場合は無視してください。',
'forgot_password_body' => 'こんにちは、{{user.friendlyName}} さん、{{siteName}}を再設定するには、このリンクをクリックしてください:&lt;{{link}}&gt;このメールに心当たりがない場合は無視してください。',
'forgot_password_heading' => '誰かがパスワードを忘れた場合:',
'forgot_password_subject' => 'パスワードを再設定する',
'four' => '4',
Expand All @@ -1198,12 +1198,12 @@
'seconds' => '',
'seven' => '7',
'six' => '6',
'test_email_body' => 'こんにちわ {{user.friendlyName}} さん、おめでとうございます! Craft はメールの送信に成功しました。あなたが使用した設定は以下の通りです:{{ settings }}',
'test_email_body' => 'こんにちは {{user.friendlyName}} さん、おめでとうございます! Craft はメールの送信に成功しました。あなたが使用した設定は以下の通りです:{{ settings }}',
'test_email_heading' => 'メールの設定を試すとき:',
'test_email_subject' => 'これはCraftからのテストメールです。',
'three' => '3',
'two' => '2',
'verify_new_email_body' => 'こんにちわ、{{user.friendlyName}} さん、このリンクをクリックして新しいメールアドレスを確認してください:&lt;{{link}}&gt;このメールに心当たりがない場合は無視してください。',
'verify_new_email_body' => 'こんにちは、{{user.friendlyName}} さん、このリンクをクリックして新しいメールアドレスを確認してください:&lt;{{link}}&gt;このメールに心当たりがない場合は無視してください。',
'verify_new_email_heading' => '誰かがメールアドレスを変更する時:',
'verify_new_email_subject' => '新しいメールアドレスを確認する',
'week' => '',
Expand Down
25 changes: 18 additions & 7 deletions src/web/assets/cp/dist/js/Craft.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! - 2019-01-15 */
/*! - 2019-01-21 */
(function($){

/** global: Craft */
Expand Down Expand Up @@ -18561,16 +18561,22 @@ Craft.TagSelectInput = Craft.BaseElementSelectInput.extend(
var $li;

for (var i = 0; i < response.tags.length; i++) {
$li = $('<li/>').appendTo($ul);
$('<a data-icon="tag"/>').appendTo($li).text(response.tags[i].title).data('id', response.tags[i].id);
$li = $('<li/>')
.appendTo($ul);

$('<a data-icon="tag"/>')
.appendTo($li)
.text(response.tags[i].title)
.data('id', response.tags[i].id)
.addClass(response.tags[i].exclude ? 'disabled' : '');
}

if (!response.exactMatch) {
$li = $('<li/>').appendTo($ul);
$('<a data-icon="plus"/>').appendTo($li).text(data.search);
}

$ul.find('> li:first-child > a').addClass('hover');
$ul.find('a:not(.disabled):first').addClass('hover');

this.searchMenu = new Garnish.Menu($menu, {
attachToElement: this.$addTagInput,
Expand All @@ -18592,9 +18598,14 @@ Craft.TagSelectInput = Craft.BaseElementSelectInput.extend(
},

selectTag: function(option) {
var $option = $(option),
id = $option.data('id'),
title = $option.text();
var $option = $(option);

if ($option.hasClass('disabled')) {
return;
}

var id = $option.data('id');
var title = $option.text();

var $element = $('<div/>', {
'class': 'element small removable',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/js/Craft.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/js/Craft.min.js.map

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions src/web/assets/cp/src/js/TagSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,22 @@ Craft.TagSelectInput = Craft.BaseElementSelectInput.extend(
var $li;

for (var i = 0; i < response.tags.length; i++) {
$li = $('<li/>').appendTo($ul);
$('<a data-icon="tag"/>').appendTo($li).text(response.tags[i].title).data('id', response.tags[i].id);
$li = $('<li/>')
.appendTo($ul);

$('<a data-icon="tag"/>')
.appendTo($li)
.text(response.tags[i].title)
.data('id', response.tags[i].id)
.addClass(response.tags[i].exclude ? 'disabled' : '');
}

if (!response.exactMatch) {
$li = $('<li/>').appendTo($ul);
$('<a data-icon="plus"/>').appendTo($li).text(data.search);
}

$ul.find('> li:first-child > a').addClass('hover');
$ul.find('a:not(.disabled):first').addClass('hover');

this.searchMenu = new Garnish.Menu($menu, {
attachToElement: this.$addTagInput,
Expand All @@ -164,9 +170,14 @@ Craft.TagSelectInput = Craft.BaseElementSelectInput.extend(
},

selectTag: function(option) {
var $option = $(option),
id = $option.data('id'),
title = $option.text();
var $option = $(option);

if ($option.hasClass('disabled')) {
return;
}

var id = $option.data('id');
var title = $option.text();

var $element = $('<div/>', {
'class': 'element small removable',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/pluginstore/dist/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/pluginstore/dist/js/app.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="release" class="changelog-release">
<div class="version">
<a :href="'#' + release.version" class="anchor"><font-awesome-icon icon="link" /></a>
<a :href="'#' + release.version" class="anchor"><icon icon="link" /></a>
<h2 :id="release.version">{{ "Version {version}"|t('app', {version: release.version}) }}</h2>
<div class="date">{{date}}</div>
<div v-if="release.critical" class="critical">{{ 'Critical'|t('app') }}</div>
Expand Down
11 changes: 11 additions & 0 deletions src/web/assets/pluginstore/src/js/components/Icon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div>
<font-awesome-icon :icon="icon" :class="cssClass" />
</div>
</template>

<script>
export default {
props: ['icon', 'cssClass'],
}
</script>
2 changes: 1 addition & 1 deletion src/web/assets/pluginstore/src/js/components/InfoHud.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="info-hud">
<v-popover placement="right">
<font-awesome-icon icon="info-circle" />
<icon icon="info-circle" />

<template slot="popover">
<slot></slot>
Expand Down
Loading

0 comments on commit 0d7c54f

Please sign in to comment.