Skip to content

Commit

Permalink
Merge branch 'release/4.4.17' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 8, 2023
2 parents d2f4a21 + d688f39 commit 75cb07c
Show file tree
Hide file tree
Showing 62 changed files with 320 additions and 215 deletions.
10 changes: 0 additions & 10 deletions .github/CODEOWNERS

This file was deleted.

20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Release Notes for Craft CMS 4

## 4.4.17 - 2023-08-08

- `meta.__names__` values in the project config are now updated throughout the process of applying incoming project config changes, rather than at the end of the request.
- The `project-config/rebuild` command now rebuilds the `meta.__names__` array from scratch. ([#13456](https://github.com/craftcms/cms/issues/13456))
- Fixed a bug where `Craft.BaseElementIndexView::this.canSelectElement()` wasn’t getting applied for lazy-loaded elements.
- Fixed a bug where setting an element query’s `status` param to `archived` would always yield zero results. ([#13465](https://github.com/craftcms/cms/issues/13465))
- Fixed a bug where `update` commands could fail on some environments.
- Fixed a bug where element thumbnails weren’t getting loaded for expanded relational field previews within element indexes.
- Fixed an error that occurred when deleting a volume with a missing filesystem type.
- Fixed a bug where Color field values were illegible within selected element index rows.
- Fixed a bug where multi-site content could be overwritten when creating a draft. ([#13451](https://github.com/craftcms/cms/issues/13451))
- Fixed a bug where some nested component names weren’t getting deleted from the `meta.__names__` array in the project config. ([#13456](https://github.com/craftcms/cms/issues/13456))
- Fixed a bug where `craft\helpers\DateTimeHelper::toDateInterval()` didn’t support negative integers. ([#13463](https://github.com/craftcms/cms/pull/13463))
- Fixed a bug where admin tables were initially displaying an empty results message rather than a loading spinner, when the initial data was loading via Ajax. ([#13459](https://github.com/craftcms/cms/issues/13459))
- Fixed a bug where garbage collection could terminate prematurely if an exception was thrown when deleting a pending user. ([#13490](https://github.com/craftcms/cms/issues/13490))
- Fixed an error that occurred if the `purify` Twig filter was applied to a `null` value. ([#13495](https://github.com/craftcms/cms/issues/13495))
- Fixed an error that could occur if a console controller’s `runAction()` method returned `null`.
- Fixed a bug where image transforms weren’t respecting their `format` settings. ([#13493](https://github.com/craftcms/cms/issues/13493))
- Fixed an information disclosure vulnerability.

## 4.4.16.1 - 2023-07-19

- Fixed a bug where lightswitch inputs weren’t always stretching to fit their labels, when there was enough space for it. ([#13452](https://github.com/craftcms/cms/issues/13452))
Expand Down
7 changes: 7 additions & 0 deletions packages/craftcms-vue/admintable/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
:detail-row-component="detailRowComponent"
:fields="fields"
:per-page="perPage"
:no-data-template="noDataTemplate"
pagination-path="pagination"
@vuetable:loaded="init"
@vuetable:loading="loading"
Expand Down Expand Up @@ -748,6 +749,12 @@
tableClass: tableClass,
};
},
noDataTemplate() {
return this.isLoading
? '<div class="spinner"></div>'
: '<div class="zilch">' + this.emptyMessage + '</div>';
},
},
watch: {
Expand Down
2 changes: 2 additions & 0 deletions src/base/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ public function getIsInitialized(): bool
/**
* Invokes a callback method when Craft is fully initialized.
*
* If Craft is already fully initialized, the callback will be invoked immediately.
*
* @param callable $callback
* @since 4.3.5
*/
Expand Down
6 changes: 4 additions & 2 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,9 @@ public function getLocalized(): ElementQueryInterface|Collection
->structureId($this->structureId)
->siteId(['not', $this->siteId])
->drafts($this->getIsDraft())
->provisionalDrafts($this->isProvisionalDraft)
// the provisionalDraft state could have just changed (e.g. `elements/save-draft`)
// so don't filter based on one or the other
->provisionalDrafts(null)
->revisions($this->getIsRevision());
}

Expand Down Expand Up @@ -4502,7 +4504,7 @@ public function getTableAttributeHtml(string $attribute): string
* attribute, rather than simply showing the attribute’s raw value.
*
* For example, if your elements have an `email` attribute that you want to wrap in a `mailto:` link, your
* getTableAttributesHtml() method could do this:
* `tableAttributeHtml()` method could do this:
*
* ```php
* switch ($attribute) {
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.4.16.1',
'version' => '4.4.17',
'schemaVersion' => '4.4.0.4',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
6 changes: 5 additions & 1 deletion src/console/ControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use yii\base\Action;
use yii\base\InvalidRouteException;
use yii\console\Exception;
use yii\console\ExitCode;
use yii\redis\Mutex as RedisMutex;

/**
Expand Down Expand Up @@ -84,7 +85,10 @@ public function options($actionID): array
public function runAction($id, $params = [])
{
try {
return parent::runAction($id, $params);
// *should* only be an int, but there are exceptions :/
/** @var int|null $response */
$response = parent::runAction($id, $params);
return $response ?? ExitCode::OK;
} finally {
if (isset($this->isolationMutexName)) {
Craft::$app->getMutex()->release($this->isolationMutexName);
Expand Down
7 changes: 5 additions & 2 deletions src/console/controllers/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use craft\models\Updates;
use craft\models\Updates as UpdatesModel;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Throwable;
use yii\base\InvalidConfigException;
Expand Down Expand Up @@ -415,7 +416,8 @@ private function _migrate(): bool

$this->stdout('Applying new migrations ... ', Console::FG_YELLOW);

$process = new Process([PHP_BINARY, $script, 'migrate/all', '--no-backup', '--no-content']);
$php = (new PhpExecutableFinder())->find() ?: 'php';
$process = new Process([$php, $script, 'migrate/all', '--no-backup', '--no-content']);
$process->setTimeout(null);
try {
$process->mustRun();
Expand Down Expand Up @@ -478,7 +480,8 @@ private function _revertComposerChanges(): void

$this->stdout('Reverting Composer changes ... ', Console::FG_YELLOW);

$process = new Process([PHP_BINARY, $script, 'update/composer-install']);
$php = (new PhpExecutableFinder())->find() ?: 'php';
$process = new Process([$php, $script, 'update/composer-install']);
$process->setTimeout(null);
try {
$process->mustRun();
Expand Down
6 changes: 5 additions & 1 deletion src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2893,7 +2893,11 @@ public function beforeDelete(): bool
public function afterDelete(): void
{
if (!$this->keepFileOnDelete) {
$this->getVolume()->deleteFile($this->getPath());
try {
$this->getVolume()->deleteFile($this->getPath());
} catch (InvalidConfigException|NotSupportedException) {
// NBD
}
}

Craft::$app->getImageTransforms()->deleteAllTransformData($this);
Expand Down
18 changes: 12 additions & 6 deletions src/elements/db/ElementQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ElementQuery extends Query implements ElementQueryInterface
public const EVENT_BEFORE_PREPARE = 'beforePrepare';

/**
* @event Event An event that is triggered at the end of preparing an element query for the query builder.
* @event CancelableEvent An event that is triggered at the end of preparing an element query for the query builder.
*/
public const EVENT_AFTER_PREPARE = 'afterPrepare';

Expand Down Expand Up @@ -1419,8 +1419,13 @@ public function prepare($builder): Query
if ($this->archived) {
$this->subQuery->andWhere(['elements.archived' => true]);
} else {
$this->subQuery->andWhere(['elements.archived' => false]);
$this->_applyStatusParam($class);

// only set archived=false if 'archived' doesn't show up in the status param
// (_applyStatusParam() will normalize $this->status to an array if applicable)
if (!is_array($this->status) || !in_array(Element::STATUS_ARCHIVED, $this->status)) {
$this->subQuery->andWhere(['elements.archived' => false]);
}
}

if ($this->trashed === false) {
Expand Down Expand Up @@ -2297,12 +2302,13 @@ private function _applyStatusParam(string $class): void
return;
}

/** @var string[]|string|null $statuses */
$statuses = $this->status;
if (!is_array($statuses)) {
$statuses = $statuses ? StringHelper::split($statuses) : [];
// Normalize the status param
if (!is_array($this->status)) {
$this->status = StringHelper::split($this->status);
}

$statuses = array_merge($this->status);

$firstVal = strtolower(reset($statuses));
if (in_array($firstVal, ['not', 'or'])) {
$glue = $firstVal;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Assets
public const INDEX_SKIP_ITEMS_PATTERN = '/.*(Thumbs\.db|__MACOSX|__MACOSX\/|__MACOSX\/.*|\.DS_STORE)$/i';

/**
* @event SetElementTableAttributeHtmlEvent The event that is triggered when defining an asset’s filename.
* @event SetAssetFilenameEvent The event that is triggered when defining an asset’s filename.
*/
public const EVENT_SET_FILENAME = 'setFilename';

Expand Down
5 changes: 4 additions & 1 deletion src/helpers/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ public static function elementPreviewHtml(
'title' => implode(', ', ArrayHelper::getColumn($elements, 'title')),
'class' => 'btn small',
'role' => 'button',
'onclick' => 'jQuery(this).replaceWith(' . Json::encode($otherHtml) . ')',
'onclick' => sprintf(
'const r=jQuery(%s);jQuery(this).replaceWith(r);Craft.cp.elementThumbLoader.load(r);',
Json::encode($otherHtml),
),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/DateTimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public static function toDateInterval(mixed $value): DateInterval|false
if (is_numeric($value)) {
// Use DateTime::diff() so the years/months/days/hours/minutes values are all populated correctly
$now = static::now(new DateTimeZone('UTC'));
$then = (clone $now)->modify("+$value seconds");
$then = (clone $now)->modify(sprintf('%s%s seconds', $value < 0 ? '-' : '+', abs($value)));
return $now->diff($then);
}

Expand Down
5 changes: 4 additions & 1 deletion src/helpers/ImageTransforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,10 @@ public static function generateTransform(
}

// Save it!
$tempFilename = FileHelper::uniqueName($asset->getFilename());

// It's important that the temp filename has the target file extension, as craft\image\Raster::saveAs() uses it
// to determine the options that should be passed to Imagine\Image\ManipulatorInterface::save().
$tempFilename = FileHelper::uniqueName(sprintf('%s.%s', $asset->getFilename(false), $format));
$tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename;
$image->saveAs($tempPath);
clearstatcache(true, $tempPath);
Expand Down
8 changes: 6 additions & 2 deletions src/image/Raster.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,17 @@ public function loadImage(string $path): self
$mimeType = FileHelper::getMimeType($path, null, false);

if ($mimeType !== null && !str_starts_with($mimeType, 'image/') && !str_starts_with($mimeType, 'application/pdf')) {
throw new ImageException(Craft::t('app', 'The file “{name}” does not appear to be an image.', ['name' => basename($path)]));
throw new ImageException(Craft::t('app', 'The file “{name}” does not appear to be an image.', [
'name' => basename($path),
]));
}

try {
$this->_image = $this->_instance->open($path);
} catch (Throwable $e) {
throw new ImageException(Craft::t('app', 'The file “{path}” does not appear to be an image.', ['path' => $path]), 0, $e);
throw new ImageException(Craft::t('app', 'The file “{name}” does not appear to be an image.', [
'name' => basename($path),
]), 0, $e);
}

// For Imagick, convert CMYK to RGB, save and re-open.
Expand Down
4 changes: 2 additions & 2 deletions src/imagetransforms/ImageTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public function deleteImageTransformFile(Asset $asset, ImageTransformIndex $tran

try {
$asset->getVolume()->getTransformFs()->deleteFile($path);
} catch (InvalidConfigException) {
// nbd
} catch (InvalidConfigException|NotSupportedException) {
// NBD
}
}

Expand Down
Loading

0 comments on commit 75cb07c

Please sign in to comment.