Skip to content

Commit

Permalink
Merge branch 'release/4.7.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 29, 2024
2 parents 17164e7 + 918a8e1 commit 887b4ca
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 76 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- develop
- '4.7'
pull_request:
permissions:
contents: read
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes for Craft CMS 4

## 4.7.1 - 2024-01-29

- Unpublished drafts no longer show “Created at” or “Updated at” metadata values. ([#14204](https://github.com/craftcms/cms/issues/14204))
- Fixed a bug where empty Dropdown fields were getting treated as dirty when unchanged.
- Fixed a bug where Recent Entries widgets were getting mangled when new entries were created via Quick Post widgets.
- Fixed an error that occurred when adding a Dropdown field condition rule, if the field contained any optgroups. ([#14224](https://github.com/craftcms/cms/issues/14224))
- Fixed a bug where Dropdown field condition rules weren’t displaying `0` options. ([#14232](https://github.com/craftcms/cms/pull/14232))

## 4.7.0 - 2024-01-23

> [!NOTE]
Expand Down
4 changes: 2 additions & 2 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -5082,10 +5082,10 @@ public function getMetadata(): array
return $icon . Html::tag('span', $label);
},
], $event->metadata, [
Craft::t('app', 'Created at') => $this->dateCreated
Craft::t('app', 'Created at') => $this->dateCreated && !$this->getIsUnpublishedDraft()
? $formatter->asDatetime($this->dateCreated, Formatter::FORMAT_WIDTH_SHORT)
: false,
Craft::t('app', 'Updated at') => $this->dateUpdated
Craft::t('app', 'Updated at') => $this->dateUpdated && !$this->getIsUnpublishedDraft()
? $formatter->asDatetime($this->dateUpdated, Formatter::FORMAT_WIDTH_SHORT)
: false,
Craft::t('app', 'Notes') => function() {
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' => '4.7.0',
'version' => '4.7.1',
'schemaVersion' => '4.5.3.0',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
2 changes: 1 addition & 1 deletion src/console/controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public function actionCloud(): int
$io = new ConsoleIO($input, $output, new HelperSet([new QuestionHelper()]));

Craft::$app->getComposer()->install([
'craftcms/cloud' => '^1.0.0',
'craftcms/cloud' => '*',
], $io);

$message = sprintf('Extension %s', $moduleInstalled ? 'updated' : 'installed');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
use yii\console\ExitCode;

/**
* Prunes orphaned matrix blocks for each site.
* Prunes orphaned Matrix blocks for each site.
*
* @author Pixel & Tonic, Inc. <[email protected]>
* @since 4.7.0
*/
class PruneOrphanedMatrixBlocksController extends Controller
{
/**
* Prunes orphaned matrix blocks for each site.
* Prunes orphaned Matrix blocks for each site.
*
* @return int
*/
Expand All @@ -40,9 +40,9 @@ public function actionIndex(): int
// get all sites
$sites = Craft::$app->getSites()->getAllSites();

// for each site get all matrix blocks with owner that doesn't exist for this site
// for each site get all Matrix blocks with owner that doesn't exist for this site
foreach ($sites as $site) {
$this->stdout(sprintf('Finding orphaned matrix blocks for site "%s" ... ', $site->getName()));
$this->stdout(sprintf('Finding orphaned Matrix blocks for site "%s" ... ', $site->getName()));

$esSubQuery = (new Query())
->from(['es' => Table::ELEMENTS_SITES])
Expand Down
4 changes: 1 addition & 3 deletions src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1686,9 +1686,7 @@ public function actionUpdateFieldLayout(): ?Response
'initialDeltaValues' => Craft::$app->getView()->getInitialDeltaValues(),
];

return $this->_asSuccess(Craft::t('app', '{type} saved.', [
'type' => Craft::t('app', 'Draft'),
]), $element, $data, true);
return $this->_asSuccess('Field layout updated.', $element, $data, true);
}

private function _fieldLayoutData(ElementInterface $element): array
Expand Down
15 changes: 9 additions & 6 deletions src/fields/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use craft\base\Element;
use craft\base\ElementInterface;
use craft\base\SortableFieldInterface;
use craft\fields\data\MultiOptionsFieldData;
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use craft\helpers\Cp;

Expand Down Expand Up @@ -107,21 +109,22 @@ private function inputHtmlInternal(mixed $value, ?ElementInterface $element, boo
}
}

$encValue = $this->encodeValue($value);
if ($encValue === null || $encValue === '') {
$encValue = '__BLANK__';
}

return Cp::selectizeHtml([
'id' => $this->getInputId(),
'describedBy' => $this->describedBy,
'name' => $this->handle,
'value' => $encValue,
'value' => $this->encodeValue($value),
'options' => $options,
'disabled' => $static,
]);
}

protected function encodeValue(MultiOptionsFieldData|OptionData|string|null $value): string|array|null
{
$encValue = parent::encodeValue($value);
return $encValue === null || $encValue === '' ? '__BLANK__' : $encValue;
}

/**
* @inheritdoc
*/
Expand Down
7 changes: 6 additions & 1 deletion src/fields/conditions/OptionsFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ protected function options(): array
/** @var BaseOptionsField $field */
$field = $this->field();
return Collection::make($field->options)
->filter(fn(array $option) => $option['value'] !== null && $option['value'] !== '' && !empty($option['label']))
->filter(fn(array $option) => (array_key_exists('value', $option) &&
$option['value'] !== null &&
$option['value'] !== '' &&
$option['label'] !== null &&
$option['label'] !== ''
))
->map(fn(array $option) => [
'value' => $option['value'],
'label' => $option['label'],
Expand Down
19 changes: 1 addition & 18 deletions src/mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use craft\helpers\App;
use craft\helpers\Template;
use craft\web\View;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Throwable;
use yii\base\InvalidConfigException;
use yii\helpers\Markdown;
Expand Down Expand Up @@ -175,22 +174,6 @@ public function send($message): bool
$message->setBcc([]);
}

try {
return parent::send($message);
} catch (TransportExceptionInterface $e) {
$eMessage = $e->getMessage();

// Remove the stack trace to get rid of any sensitive info.
$eMessage = substr($eMessage, 0, strpos($eMessage, 'Stack trace:') - 1);
Craft::warning('Error sending email: ' . $eMessage);

// Save the exception on the message, for plugins to make use of
if ($message instanceof Message) {
$message->error = $e;
}

$this->afterSend($message, false);
return false;
}
return parent::send($message);
}
}
2 changes: 1 addition & 1 deletion src/web/assets/recententries/dist/RecentEntriesWidget.js

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

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

41 changes: 11 additions & 30 deletions src/web/assets/recententries/src/RecentEntriesWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,31 @@
$widget: null,
$body: null,
$container: null,
$tbody: null,
$list: null,
hasEntries: null,

init: function (widgetId, params) {
this.params = params;
this.$widget = $('#widget' + widgetId);
this.$body = this.$widget.find('.body:first');
this.$container = this.$widget.find('.recententries-container:first');
this.$tbody = this.$container.find('tbody:first');
this.hasEntries = !!this.$tbody.length;
this.$container = this.$body.find('.recententries-container:first');
this.$list = this.$container.find('ol:first');
this.hasEntries = !!this.$list.length;

this.$widget.data('widget').on('destroy', this.destroy.bind(this));

Craft.RecentEntriesWidget.instances.push(this);
},

addEntry: function (entry) {
this.$container.css('margin-top', 0);
var oldHeight = this.$container.height();

if (!this.hasEntries) {
// Create the table first
var $table = $('<table class="data fullwidth"/>').prependTo(
this.$container
);
this.$tbody = $('<tbody/>').appendTo($table);
// Create the list first
this.$list = $('<ol/>').appendTo(this.$container);
}

this.$tbody.prepend(
'<tr>' +
'<td>' +
'<a href="' +
entry.url +
'">' +
this.$list.prepend(
'<li class="widget__list-item">' +
`<a href="${entry.url}">` +
Craft.escapeHtml(entry.title) +
'</a> ' +
'<span class="light">' +
Expand All @@ -56,24 +47,14 @@
: '')
) +
'</span>' +
'</td>' +
'</tr>'
'</li>'
);

var newHeight = this.$container.height(),
heightDiff = newHeight - oldHeight;

this.$container.css('margin-top', -heightDiff);

var props = {'margin-top': 0};

// Also animate the "No entries exist" text out of view
if (!this.hasEntries) {
props['margin-bottom'] = -oldHeight;
this.$container.find('.zilch').remove();
this.hasEntries = true;
}

this.$container.velocity(props);
},

destroy: function () {
Expand Down
Loading

0 comments on commit 887b4ca

Please sign in to comment.