Skip to content

Commit

Permalink
Merge branch 'develop' into 3.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
#	src/config/app.php
#	src/controllers/GraphqlController.php
#	src/services/Gql.php
  • Loading branch information
andris-sevcenko committed Oct 16, 2019
2 parents 3526178 + 379ab3c commit 10a312a
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 19 deletions.
18 changes: 16 additions & 2 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Release Notes for Craft CMS 3.x

## 3.3.11 - 2019-10-16

### Added
- Added `craft\events\ExecuteGqlQueryEvent`.
- Added `craft\services\Gql::EVENT_BEFORE_EXECUTE_GQL_QUERY`.
- Added `craft\services\Gql::EVENT_AFTER_EXECUTE_GQL_QUERY`.
- Added `craft\services\Gql::executeQuery()`.

### Changed
- Dropdown and Multi-select fields can now have duplicate option labels, as long as they are in different optgroups. ([#5105](https://github.com/craftcms/cms/issues/5105))

### Fixed
- Fixed a bug where user email changes were going through email verification even if someone with permission to administrate users was making the change. ([#5088](https://github.com/craftcms/cms/issues/5088))
- Fixed an error that could occur when duplicating entries with Matrix blocks. ([#5097](https://github.com/craftcms/cms/issues/5097))

## 3.3.10 - 2019-10-15

### Added
Expand All @@ -11,7 +26,6 @@
- Fixed a bug where Craft wasn’t passing assets’ MIME types to cloud storage services when saving them. ([#5052](https://github.com/craftcms/cms/issues/5052))
- Fixed a bug where Assets fields’ image thumbnails weren’t getting refreshed after images were edited. ([#4212](https://github.com/craftcms/cms/issues/4212))
- Fixed a bug where the `index-assets` command would bail as soon as it came across a file with a disallowed file extension. ([#5086](https://github.com/craftcms/cms/issues/5086))
- Fixed a bug where user email changes were going through email verification even if someone with permission to administrate users was making the change. ([#5088](https://github.com/craftcms/cms/issues/5088))
- Fixed a bug where it wasn’t possible to eager-load Matrix blocks that belong to a draft or revision. ([#5031](https://github.com/craftcms/cms/issues/5031))
- Fixed a bug where the `setup` command would think that Craft was installed when it wasn’t. ([#5093](https://github.com/craftcms/cms/issues/5093))
- Fixed an error that could occur when syncing the project config if a Matrix field had been changed to something else. ([#4015](https://github.com/craftcms/cms/issues/4015))
Expand Down Expand Up @@ -2319,7 +2333,7 @@
- `craft\helpers\StringHelper::toKebabCase()`, `toCamelCase()`, `toPascalCase()`, and `toSnakeCase()` now treat camelCase’d and PascalCale’d strings as multiple words. ([#3090](https://github.com/craftcms/cms/issues/3090))

### Fixed
- Fixed a bug where `craft\i18n\I18N::getPrimarySiteLocale()` and `getPrimarySiteLocaleId()` were returning locale info for the _first_ site, rather than the primary one. ([#3063](https://github.com/craftcms/cms/issues/3063))
- Fixed a bug where `craft\i18n\I18N::getPrimarySiteLocale()` and `getPrimarySiteLocaleId()` were returning locale info for the _first_ site, rather than the primary one. ([#3063](https://github.com/craftcms/cms/issues/3063))
- Fixed a bug where element index pages were loading all elements in the view, rather than waiting for the user to scroll to the bottom of the page before loading the next batch. ([#3068](https://github.com/craftcms/cms/issues/3068))
- Fixed a bug where sites listed in the Control Panel weren’t always in the correct sort order. ([#3065](https://github.com/craftcms/cms/issues/3065))
- Fixed an error that occurred when users attempted to create new entries within entry selector modals, for a section they didn’t have permission to publish peer entries in. ([#3069](https://github.com/craftcms/cms/issues/3069))
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/GraphqlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public function actionApi(): Response

try {
$schemaDef = $gqlService->getSchemaDef($schema, $devMode || StringHelper::contains($query, '__schema'));
$result = GraphQL::executeQuery($schemaDef, $query, null, null, $variables, $operationName, null, $gqlService->getValidationRules($devMode))
->toArray(true);
$result = $gqlService->executeQuery($schemaDef, $query, $variables, $operationName);
} catch (\Throwable $e) {
Craft::$app->getErrorHandler()->logException($e);

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ public function actionSaveUser()
if ($requireEmailVerification && (
!$currentUser ||
(!$currentUser->admin && !$currentUser->can('administrateUsers')) ||
$request->getBodyParam('sendVerificationEmail', true)
$request->getBodyParam('sendVerificationEmail')
)) {
// Save it as an unverified email for now
$user->unverifiedEmail = $newEmail;
Expand Down
58 changes: 58 additions & 0 deletions src/events/ExecuteGqlQueryEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/

namespace craft\events;

use GraphQL\Type\Schema;
use yii\base\Event;

/**
* ExecuteGqlQueryEvent event class.
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.3.11
*/
class ExecuteGqlQueryEvent extends Event
{
// Properties
// =========================================================================

/**
* @var Schema The GraphQL schema used for this query.
*/
public $schemaDef;

/**
* @var string The GraphQL query being executed
*/
public $query;

/**
* @var array The variables used for this query.
*/
public $variables = [];

/**
* @var string|null The name of the operation to use if requestString contains multiple possible operations.
*/
public $operationName;

/**
* @var mixed|null The context that is shared between all resolvers.
*/
public $context;

/**
* @var mixed|null The root value to use when resolving the top-level object fields.
*/
public $rootValue;

/**
* @var array|null The query result to be returned.
*/
public $result;
}
6 changes: 4 additions & 2 deletions src/fields/BaseOptionsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ public function validateOptions()
$values = [];
$hasDuplicateLabels = false;
$hasDuplicateValues = false;
$optgroup = '__root__';

foreach ($this->options as &$option) {
// Ignore optgroups
if (array_key_exists('optgroup', $option)) {
$optgroup = $option['optgroup'];
continue;
}

$label = (string)$option['label'];
$value = (string)$option['value'];
if (isset($labels[$label])) {
if (isset($labels[$optgroup][$label])) {
$option['label'] = [
'value' => $label,
'hasErrors' => true,
Expand All @@ -138,7 +140,7 @@ public function validateOptions()
];
$hasDuplicateValues = true;
}
$labels[$label] = $values[$value] = true;
$labels[$optgroup][$label] = $values[$value] = true;
}

if ($hasDuplicateLabels) {
Expand Down
22 changes: 12 additions & 10 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,17 +776,19 @@ public function duplicateElement(ElementInterface $element, array $newAttributes
$siteClone->setAttributes($newAttributes, false);
$siteClone->siteId = $siteInfo['siteId'];

// Make sure it has a valid slug
(new SlugValidator())->validateAttribute($siteClone, 'slug');
if ($siteClone->hasErrors('slug')) {
throw new InvalidElementException($siteClone, "Element {$element->id} could not be duplicated for site {$siteInfo['siteId']}: " . $siteClone->getFirstError('slug'));
}
if ($element::hasUris()) {
// Make sure it has a valid slug
(new SlugValidator())->validateAttribute($siteClone, 'slug');
if ($siteClone->hasErrors('slug')) {
throw new InvalidElementException($siteClone, "Element {$element->id} could not be duplicated for site {$siteInfo['siteId']}: " . $siteClone->getFirstError('slug'));
}

// Set a unique URI on the site clone
try {
ElementHelper::setUniqueUri($siteClone);
} catch (OperationAbortedException $e) {
// Oh well, not worth bailing over
// Set a unique URI on the site clone
try {
ElementHelper::setUniqueUri($siteClone);
} catch (OperationAbortedException $e) {
// Oh well, not worth bailing over
}
}

if (!$this->_saveElementInternal($siteClone, false, false)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/db/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public function testDateUpdated()

// Save it again. Ensure dateUpdated is the same, as nothing has changed.
$session->save();
$this->assertSame($session->dateUpdated, $oldDate->format('Y-m-d H:i:s'));
$this->tester->assertEqualDates($this, $session->dateUpdated, $oldDate->format('Y-m-d H:i:s'), 1);

// Save it again with a new value. Ensure dateUpdated is now current.
$date = new DateTime('now', $dateTimeZone);
$this->assertGreaterThan($oldDate, $date);

$session->token = 'test2';
$session->save();
$this->assertSame($session->dateUpdated, $date->format('Y-m-d H:i:s'));
$this->tester->assertEqualDates($this, $session->dateUpdated, $date->format('Y-m-d H:i:s'), 1);
}

/**
Expand Down

0 comments on commit 10a312a

Please sign in to comment.