Skip to content

Commit

Permalink
Merge branch 'release/4.4.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Mar 9, 2023
2 parents 0c7834c + 0af00dc commit 0f27b72
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 83 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- develop
- v3
- 4.4
pull_request:
permissions:
contents: read
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Release Notes for Craft CMS 4

## 4.4.1 - 2023-03-09

- Fixed a bug where it wasn’t possible to select subfolders on the Assets index page. ([#12802](https://github.com/craftcms/cms/issues/12802))
- Fixed a bug where element index search inputs were losing focus when the element listing was updated. ([#12846](https://github.com/craftcms/cms/issues/12846))
- Fixed a bug where the database driver was being referenced as “MySQL” when using MariaDB. ([#12827](https://github.com/craftcms/cms/issues/12827))
- Fixed a bug where users weren’t able to select assets within Assets fields, if they didn’t have full permissions for the volume. ([#12851](https://github.com/craftcms/cms/issues/12851))
- Fixed a bug where the Assets index page’s URL would get updated incorrectly when renaming a subfolder.
- Fixed a bug where non-admin users weren’t able to view Single section entries. ([#12838](https://github.com/craftcms/cms/issues/12838))
- Fixed an error that could occur when saving an element with eager-loaded relations. ([#12839](https://github.com/craftcms/cms/issues/12839))
- Fixed a bug where Customize Sources modals weren’t showing source headings with no subsequent sources. ([#12840](https://github.com/craftcms/cms/issues/12840))
- Fixed a bug where `entrify` commands could leave the database and project config data in inconsistent states, if aborted prematurely. ([#12850](https://github.com/craftcms/cms/pull/12850))
- Fixed a bug where the `entrify/global-set` command wasn’t always suggesting the command to run on other environments.
- Fixed a bug where the Assets index page would appear to keep loading indefinitely after renaming a subfolder.
- Fixed a bug where folders within asset indexes were getting the current site name appended to them, on multi-site installs. ([#12852](https://github.com/craftcms/cms/issues/12852))
- Fixed a SQL error that could occur when updating to Craft 4.4 on PostgreSQL. ([#12855](https://github.com/craftcms/cms/issues/12855))
- Added `craft\db\Connection::getDriverLabel()`.

## 4.4.0 - 2023-03-08

### Content Management
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.0',
'version' => '4.4.1',
'schemaVersion' => '4.4.0.4',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
20 changes: 17 additions & 3 deletions src/console/controllers/EntrifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function actionCategories(string $categoryGroup): int
return ExitCode::UNSPECIFIED_ERROR;
}

$projectConfigService = Craft::$app->getProjectConfig();
$projectConfigChanged = false;

if (
Expand All @@ -127,6 +128,9 @@ public function actionCategories(string $categoryGroup): int
$author = $this->_author();
} catch (InvalidConfigException $e) {
$this->stderr($e->getMessage() . PHP_EOL, Console::FG_RED);
if ($projectConfigChanged) {
$projectConfigService->saveModifiedConfigData();
}
return ExitCode::UNSPECIFIED_ERROR;
}

Expand Down Expand Up @@ -217,7 +221,6 @@ public function actionCategories(string $categoryGroup): int

$this->success('Categories converted.');

$projectConfigService = Craft::$app->getProjectConfig();
if (!$projectConfigService->readOnly) {
if (!$categoryGroup->dateDeleted && $this->confirm("Delete the “{$categoryGroup}” category group?", true)) {
$this->do('Deleting category group', function() use ($categoryGroup) {
Expand Down Expand Up @@ -279,6 +282,7 @@ public function actionTags(string $tagGroup): int
return ExitCode::UNSPECIFIED_ERROR;
}

$projectConfigService = Craft::$app->getProjectConfig();
$projectConfigChanged = false;

if (
Expand All @@ -302,6 +306,9 @@ public function actionTags(string $tagGroup): int
$author = $this->_author();
} catch (InvalidConfigException $e) {
$this->stderr($e->getMessage() . PHP_EOL, Console::FG_RED);
if ($projectConfigChanged) {
$projectConfigService->saveModifiedConfigData();
}
return ExitCode::UNSPECIFIED_ERROR;
}

Expand Down Expand Up @@ -353,7 +360,6 @@ public function actionTags(string $tagGroup): int

$this->success('Tags converted.');

$projectConfigService = Craft::$app->getProjectConfig();
if (!$projectConfigService->readOnly) {
if (!$tagGroup->dateDeleted && $this->confirm("Delete the “{$tagGroup}” tag group?", true)) {
$this->do('Deleting tag group', function() use ($tagGroup) {
Expand Down Expand Up @@ -436,10 +442,18 @@ public function actionGlobalSet(string $globalSet): int
$entryType = $this->_entryType();
} catch (InvalidConfigException $e) {
$this->stderr($e->getMessage() . PHP_EOL, Console::FG_RED);
if ($projectConfigChanged) {
Craft::$app->getProjectConfig()->saveModifiedConfigData();
}
return ExitCode::UNSPECIFIED_ERROR;
}

$this->do("Converting “{$globalSet->name}", function() use ($section, $entryType, $globalSet) {
$this->do("Converting “{$globalSet->name}", function() use (
$section,
$entryType,
$globalSet,
&$projectConfigChanged,
) {
if (!$globalSet->dateDeleted) {
Craft::$app->getGlobals()->deleteSet($globalSet);
$projectConfigChanged = true;
Expand Down
20 changes: 20 additions & 0 deletions src/db/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ public function getIsPgsql(): bool
return $this->getDriverName() === Connection::DRIVER_PGSQL;
}

/**
* Returns the human-facing driver label (MySQL, MariaDB, or PostgreSQL).
*
* @return string
* @since 4.4.1
*/
public function getDriverLabel(): string
{
if ($this->getIsMysql()) {
// Actually MariaDB though?
if (StringHelper::contains($this->getSchema()->getServerVersion(), 'mariadb', false)) {
return 'MariaDB';
}

return 'MySQL';
}

return 'PostgreSQL';
}

/**
* Returns whether the database supports 4+ byte characters.
*
Expand Down
1 change: 1 addition & 0 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,7 @@ public function getHtmlAttributes(string $context): array
'data' => [
'is-folder' => true,
'folder-id' => $this->folderId,
'folder-name' => $this->title,
'source-path' => Json::encode($this->sourcePath),
'has-children' => Craft::$app->getAssets()->foldersExist(['parentId' => $this->folderId]),
],
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ public function canDelete(User $user): bool
/** @var static|DraftBehavior $this */
return (
$this->creatorId === $user->id ||
$user->can("deletePeerEntries:$section->uid")
$user->can("deletePeerEntryDrafts:$section->uid")
);
}

Expand Down
19 changes: 14 additions & 5 deletions src/elements/db/EntryQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,21 @@ private function _applyAuthParam(?bool $value, string $permissionPrefix, string
$unauthorizedSectionIds = [];

foreach (Craft::$app->getSections()->getAllSections() as $section) {
if ($user->can("$peerPermissionPrefix:$section->uid")) {
$fullyAuthorizedSectionIds[] = $section->id;
} elseif ($section->type !== Section::TYPE_SINGLE && $user->can("$permissionPrefix:$section->uid")) {
$partiallyAuthorizedSectionIds[] = $section->id;
if ($section->type === Section::TYPE_SINGLE) {
// Singles don't have peer permissions
if ($user->can("$permissionPrefix:$section->uid")) {
$fullyAuthorizedSectionIds[] = $section->id;
} else {
$unauthorizedSectionIds[] = $section->id;
}
} else {
$unauthorizedSectionIds[] = $section->id;
if ($user->can("$peerPermissionPrefix:$section->uid")) {
$fullyAuthorizedSectionIds[] = $section->id;
} elseif ($user->can("$permissionPrefix:$section->uid")) {
$partiallyAuthorizedSectionIds[] = $section->id;
} else {
$unauthorizedSectionIds[] = $section->id;
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/fields/BaseRelationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,13 @@ protected function searchKeywords(mixed $value, ElementInterface $element): stri
/** @var ElementQuery|Collection $value */
$titles = [];

foreach ($this->_all($value, $element)->all() as $relatedElement) {
if ($value instanceof Collection) {
$value = $value->all();
} else {
$value = $this->_all($value, $element)->all();
}

foreach ($value as $relatedElement) {
$titles[] = (string)$relatedElement;
}

Expand Down
20 changes: 5 additions & 15 deletions src/migrations/m221027_160703_add_image_transform_fill.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use craft\db\Migration;
use craft\db\Table;
use craft\services\ProjectConfig;
use yii\db\Exception;

/**
* m221027_160703_add_image_transform_fill migration.
Expand All @@ -24,7 +23,10 @@ public function safeUp(): bool

$modeOptions = ['stretch', 'fit', 'crop', 'letterbox'];
if ($this->db->getIsPgsql()) {
// Manually construct the SQL for Postgres
// imagetransforms used to be assettransforms, so try dropping the constraint with both table names
$this->execute(sprintf('alter table %s drop constraint if exists %s', Table::IMAGETRANSFORMS, '{{%imagetransforms_mode_check}}'));
$this->execute(sprintf('alter table %s drop constraint if exists %s', Table::IMAGETRANSFORMS, '{{%assettransforms_mode_check}}'));

$check = '[[mode]] in (';
foreach ($modeOptions as $i => $value) {
if ($i !== 0) {
Expand All @@ -33,19 +35,7 @@ public function safeUp(): bool
$check .= $this->db->quoteValue($value);
}
$check .= ')';
$tryConstraints = [
'{{%imagetransforms_mode_check}}',
'{{%assettransforms_mode_check}}',
];
foreach ($tryConstraints as $constraint) {
try {
$sql = sprintf('alter table %s drop constraint %s, add check (%s)', Table::IMAGETRANSFORMS, $constraint, $check);
$this->execute($sql);
break;
} catch (Exception) {
// try the next one...
}
}
$this->execute(sprintf('alter table %s add check (%s)', Table::IMAGETRANSFORMS, $check));
} else {
$this->alterColumn(Table::IMAGETRANSFORMS, 'mode', $this->enum('mode', $modeOptions)->notNull()->defaultValue('crop'));
}
Expand Down
3 changes: 1 addition & 2 deletions src/services/ElementSources.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public function getSources(string $elementType, string $context = self::CONTEXT_
$sources = $nativeSources;
}

// Clear out any unwanted headings and return
return static::filterExtraHeadings($sources);
return $sources;
}

/**
Expand Down
11 changes: 3 additions & 8 deletions src/utilities/SystemReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,9 @@ private static function _addVersion(array &$info, string $label, string $package
private static function _dbDriver(): string
{
$db = Craft::$app->getDb();

if ($db->getIsMysql()) {
$driverName = 'MySQL';
} else {
$driverName = 'PostgreSQL';
}

return $driverName . ' ' . App::normalizeVersion($db->getSchema()->getServerVersion());
$label = $db->getDriverLabel();
$version = App::normalizeVersion($db->getSchema()->getServerVersion());
return "$label $version";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions src/web/assets/cp/src/js/AssetIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,18 @@ Craft.AssetIndex = Craft.BaseElementIndex.extend(
if (!this.settings.foldersOnly && this.sourcePath.length) {
const currentFolder = this.sourcePath[this.sourcePath.length - 1];
if (currentFolder.folderId) {
this.uploader.setParams({
folderId: currentFolder.folderId,
});
if (this.uploader) {
this.uploader.setParams({
folderId: currentFolder.folderId,
});
}

// will the user be allowed to move items in this folder?
const canMoveSubItems = !!currentFolder.canMoveSubItems;
this.settings.selectable = canMoveSubItems;
this.settings.multiSelect = canMoveSubItems;
this.settings.selectable =
this.settings.selectable || canMoveSubItems;
this.settings.multiSelect =
this.settings.multiSelect || canMoveSubItems;
}
}

Expand Down Expand Up @@ -371,6 +375,17 @@ Craft.AssetIndex = Craft.BaseElementIndex.extend(
this.base();
},

getViewSettings: function () {
const settings = {};

if (this.settings.context === 'index') {
// Allow folders to be selected
settings.canSelectElement = () => true;
}

return settings;
},

getViewParams: function () {
const data = Object.assign(this.base(), {
showFolders: this.settings.showFolders,
Expand Down Expand Up @@ -584,12 +599,14 @@ Craft.AssetIndex = Craft.BaseElementIndex.extend(
this.addListener(this.$elements, 'keydown', this._onKeyDown.bind(this));
this.view.elementSelect.on('focusItem', this._onElementFocus.bind(this));

this.$listedFolders = $newElements.find('.element[data-is-folder]');
this.$listedFolders = $newElements.find(
'.element[data-is-folder][data-folder-name]'
);
for (let i = 0; i < this.$listedFolders.length; i++) {
const $folder = this.$listedFolders.eq(i);
const $label = $folder.find('.label');
const folderId = parseInt($folder.data('folder-id'));
const folderName = $folder.attr('title');
const folderName = $folder.data('folder-name');
const label = Craft.t('app', '{name} folder', {
name: folderName,
});
Expand Down Expand Up @@ -840,12 +857,14 @@ Craft.AssetIndex = Craft.BaseElementIndex.extend(
const sourcePath = this.sourcePath.slice();
sourcePath[sourcePath.length - 1].label = response.data.newName;
sourcePath[sourcePath.length - 1].uri =
sourcePath[sourcePath.length - 1].uri + `/${response.data.newName}`;
sourcePath[sourcePath.length - 2].uri + `/${response.data.newName}`;
this.sourcePath = sourcePath;
})
.catch(({response}) => {
this.setIndexAvailable();
alert(response.data.message);
})
.finally(() => {
this.setIndexAvailable();
});
},

Expand Down
Loading

0 comments on commit 0f27b72

Please sign in to comment.