Skip to content

Commit

Permalink
Merge branch 'release/3.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Sep 27, 2019
2 parents 6c47e2d + e380f87 commit 8cf2d3e
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 89 deletions.
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ignore:
- "src/views"
- "src/web/assets"
- "bootstrap"
- "docs"
- "lib"
- "tests"
- "vendor"
16 changes: 16 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Release Notes for Craft CMS 3.x

## 3.3.6 - 2019-09-27

### Added
- Added `craft\base\ElementInterface::getIsHomepage()`. ([#4993](https://github.com/craftcms/cms/issues/4993))
- Added `craft\base\Element::HOMEPAGE_URI`.

### Changed
- Updated Garnish to 0.1.31.

### Fixed
- Fixed a bug where some HTML in the Control Panel was getting improperly encoded. ([#5002](https://github.com/craftcms/cms/issues/5002))
- Fixed a bug where `craft\helper\UrlHelper` wasn’t encoding `+` and `&` characters in query param values.
- Fixed an error where GraphQL would sometimes not return a proper error message. ([#4999](https://github.com/craftcms/cms/issues/4999))
- Fixed a bug where HUDs could be positioned incorrectly when first opened. ([#5004](https://github.com/craftcms/cms/issues/5004))
- Fixed a bug where HUD tip images could be pointing the wrong way for RTL languages.

## 3.3.5 - 2019-09-25

### Added
Expand Down
1 change: 0 additions & 1 deletion codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ coverage:
- src/views/*
- src/web/assets/*
- bootstrap/*
- docs/*
- lib/*
- tests/*
- vendor/*
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.3.5",
"version": "3.3.6",
"keywords": [
"cms",
"craftcms",
Expand Down
2 changes: 1 addition & 1 deletion lib/garnishjs/garnish.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/garnishjs/garnish.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"es6-promise": "^4.2.8",
"event-stream": "3.3.4",
"fabric": "^1.7.19",
"garnishjs": "^0.1.30",
"garnishjs": "^0.1.31",
"graphiql": "^0.14.2",
"grunt": "^1.0.3",
"grunt-contrib-concat": "latest",
Expand Down
20 changes: 14 additions & 6 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ abstract class Element extends Component implements ElementInterface
// Constants
// =========================================================================

const HOMEPAGE_URI = '__home__';

// Statuses
// -------------------------------------------------------------------------

Expand Down Expand Up @@ -1369,6 +1371,14 @@ public function getRoute()
return $this->route();
}

/**
* @inheritdoc
*/
public function getIsHomepage(): bool
{
return $this->uri === self::HOMEPAGE_URI;
}

/**
* @inheritdoc
*/
Expand All @@ -1378,7 +1388,7 @@ public function getUrl()
return null;
}

$path = ($this->uri === '__home__') ? '' : $this->uri;
$path = $this->getIsHomepage() ? '' : $this->uri;
return UrlHelper::siteUrl($path, null, null, $this->siteId);
}

Expand Down Expand Up @@ -1439,7 +1449,7 @@ public function getPreviewTargets(): array
'label' => Craft::t('app', 'Primary {type} page', [
'type' => StringHelper::toLowerCase(static::displayName()),
]),
'url' => $this->uri === '__home__' ? '' : $this->uri
'url' => $this->getIsHomepage() ? '' : $this->uri
];
}

Expand Down Expand Up @@ -2391,9 +2401,7 @@ protected function tableAttributeHtml(string $attribute): string
$url = $this->getUrl();

if ($url !== null) {
$value = $this->uri;

if ($value === '__home__') {
if ($this->getIsHomepage()) {
$value = Html::tag('span', '', [
'data-icon' => 'home',
'title' => Craft::t('app', 'Homepage'),
Expand All @@ -2410,7 +2418,7 @@ protected function tableAttributeHtml(string $attribute): string
$replace[] = $wordSeparator . '<wbr>';
}

$value = str_replace($find, $replace, $value);
$value = str_replace($find, $replace, $this->uri);
}

return Html::a(Html::tag('span', $value, ['dir' => 'ltr']), $url, [
Expand Down
8 changes: 8 additions & 0 deletions src/base/ElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,14 @@ public function getSearchKeywords(string $attribute): string;
*/
public function getRoute();

/**
* Returns whether this element represents the site homepage.
*
* @retern bool
* @since 3.3.6
*/
public function getIsHomepage(): bool;

/**
* Returns the element’s full URL.
*
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '3.3.5',
'version' => '3.3.6',
'schemaVersion' => '3.3.3',
'minVersionRequired' => '2.6.2788',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/GraphqlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,15 @@ public function actionApi(): Response
$result = GraphQL::executeQuery($schemaDef, $query, null, null, $variables, $operationName)
->toArray(true);
} catch (\Throwable $e) {
throw new GqlException('Something went wrong when processing the GraphQL query.', 0, $e);
Craft::$app->getErrorHandler()->logException($e);

return $this->asJson([
'errors' => [
[
'message' => Craft::$app->getConfig()->getGeneral()->devMode ? $e->getMessage() : Craft::t('app', 'Something went wrong when processing the GraphQL query.'),
]
],
]);
}

return $this->asJson($result);
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/SectionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace craft\controllers;

use Craft;
use craft\base\Element;
use craft\elements\Entry;
use craft\helpers\Json;
use craft\helpers\UrlHelper;
Expand Down Expand Up @@ -171,7 +172,7 @@ public function actionSaveSection()
$siteSettings->siteId = $site->id;

if ($section->type === Section::TYPE_SINGLE) {
$siteSettings->uriFormat = ($postedSettings['singleHomepage'] ?? false) ? '__home__' : ($postedSettings['singleUri'] ?? null);
$siteSettings->uriFormat = ($postedSettings['singleHomepage'] ?? false) ? Element::HOMEPAGE_URI : ($postedSettings['singleUri'] ?? null);
} else {
$siteSettings->uriFormat = $postedSettings['uriFormat'] ?? null;
$siteSettings->enabledByDefault = (bool)$postedSettings['enabledByDefault'];
Expand Down
2 changes: 1 addition & 1 deletion src/gql/TypeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function loadType(string $type): Type
return $loader();
}

throw new GqlException('Tried to load an unregistered type „' . $type . '”. This can indicate both a typo in the query or a token permission mismatch.');
throw new GqlException('Tried to load an unregistered type „' . $type . '”. This can indicate both a typo in the query or an issue with the schema used.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ElementHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function isTempSlug(string $slug): bool
public static function createSlug(string $str): string
{
// Special case for the homepage
if ($str === '__home__') {
if ($str === Element::HOMEPAGE_URI) {
return $str;
}

Expand Down
31 changes: 23 additions & 8 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,23 @@ public static function isFullUrl(string $url): bool
*/
public static function buildQuery(array $params): string
{
// Decode and convert `[x]`s to `[]`
return preg_replace('/\[[0-9]+\]/u', '[]', urldecode(http_build_query($params)));
if (empty($params)) {
return '';
}
// build the query string
$query = http_build_query($params);
if ($query === '') {
return '';
}
// Decode the param names and a few select chars in param values
$params = [];
foreach (explode('&', $query) as $param) {
list($n, $v) = array_pad(explode('=', $param, 2), 2, '');
$n = preg_replace('/\[[0-9]+\]/u', '[]', urldecode($n));
$v = str_replace(['%2F', '%7B', '%7D'], ['/', '{', '}'], $v);
$params[] = "$n=$v";
}
return implode('&', $params);
}

/**
Expand All @@ -99,8 +114,8 @@ public static function urlWithParams(string $url, $params): string
$fragment = $fragment ?? $baseFragment;

// Append to the base URL and return
if (!empty($params)) {
$url .= '?' . static::buildQuery($params);
if (($query = static::buildQuery($params)) !== '') {
$url .= '?' . $query;
}
if ($fragment !== null) {
$url .= '#' . $fragment;
Expand All @@ -125,8 +140,8 @@ public static function removeParam(string $url, string $param): string
unset($params[$param]);

// Rebuild
if (!empty($params)) {
$url .= '?' . static::buildQuery($params);
if (($query = static::buildQuery($params)) !== '') {
$url .= '?' . $query;
}
if ($fragment !== null) {
$url .= '#' . $fragment;
Expand Down Expand Up @@ -650,8 +665,8 @@ private static function _createUrl(string $path, $params, string $scheme = null,
}
}

if (!empty($params)) {
$url .= '?' . static::buildQuery($params);
if (($query = static::buildQuery($params)) !== '') {
$url .= '?' . $query;
}

if ($fragment !== null) {
Expand Down
36 changes: 9 additions & 27 deletions src/icons/circle-c-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function getElementByUri(string $uri, int $siteId = null, bool $enabledOn
}

if ($uri === '') {
$uri = '__home__';
$uri = Element::HOMEPAGE_URI;
}

if ($siteId === null) {
Expand Down
6 changes: 3 additions & 3 deletions src/templates/_includes/forms/field.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{%- set labelId = (labelId is defined ? labelId : (id is defined ? id~'-label' : null)) %}
{%- set fieldId = (fieldId is defined ? fieldId : (id is defined ? id~'-field' : null)) %}
{%- set label %}{% filter raw %}{% block label %}{{ label is defined and label != '__blank__' ? label }}{% endblock %}{% endfilter %}{% endset %}
{%- set label = label is defined and label != '__blank__' ? label : (block('label') ?? null) %}
{%- set siteId = ((craft.app.getIsMultiSite() and siteId is defined) ? siteId : null) %}
{%- set site = (siteId ? craft.app.sites.getSiteById(siteId) : null) %}
{%- set instructions %}{% filter raw %}{% block instructions %}{{ instructions ?? '' }}{% endblock %}{% endfilter %}{% endset %}
{%- set instructions = instructions ?? block('instructions') ?? null %}
{%- set tip = tip ?? block('tip') ?? null %}
{%- set warning %}{% filter raw %}{% block warning %}{{ warning ?? '' }}{% endblock %}{% endfilter %}{% endset %}
{%- set warning = warning ?? block('warning') ?? null %}
{%- set orientation = (site ? craft.app.i18n.getLocaleById(site.language) : craft.app.locale).getOrientation() %}
{%- set translatable = translatable ?? (site is not same as(null)) %}
{%- set errors = (errors is defined ? errors : null) -%}
Expand Down
6 changes: 3 additions & 3 deletions src/templates/_layouts/cp.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
{% set licensedEdition = craft.app.getLicensedEdition() %}
{% set isTrial = licensedEdition is not same as(null) and licensedEdition is not same as(CraftEdition) %}

{% set sidebar %}{% filter trim|raw %}{% block sidebar %}{{ sidebar ?? '' }}{% endblock %}{% endfilter %}{% endset %}
{% set details %}{% filter trim|raw %}{% block details %}{{ details ?? '' }}{% endblock %}{% endfilter %}{% endset %}
{% set footer %}{% filter trim|raw %}{% block footer %}{{ footer ?? '' }}{% endblock %}{% endfilter %}{% endset %}
{% set sidebar = (sidebar ?? block('sidebar') ?? '')|trim %}
{% set details = (details ?? block('details') ?? '')|trim %}
{% set footer = (footer ?? block('footer') ?? '')|trim %}
{% set crumbs = crumbs ?? null %}

{% set showHeader = showHeader ?? true %}
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,7 @@ ul.tree,
}

.tip-right {
@include right(-15px);
right: -15px;
width: 15px;
height: 30px;
background-image: url(../images/hudtip_right.png);
Expand Down
4 changes: 1 addition & 3 deletions src/web/assets/cp/dist/css/craft.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/craft.css.map

Large diffs are not rendered by default.

Loading

0 comments on commit 8cf2d3e

Please sign in to comment.