Skip to content

Commit

Permalink
Merge branch 'release/4.4.15' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jul 3, 2023
2 parents 31c6d40 + d63c37c commit 273dfd3
Show file tree
Hide file tree
Showing 78 changed files with 755 additions and 319 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- develop
pull_request:
types:
- opened
permissions:
contents: read
concurrency:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Release Notes for Craft CMS 4

## 4.4.15 - 2023-07-03

- The control panel footer now includes a message about active trials, with a link to purchase the licenses.
- Tags fields now only show up to five suggestions. ([#13322](https://github.com/craftcms/cms/issues/13322))
- The `up`, `migrate/up`, and `migrate/all` commands now revert any project config changes created by migrations on failure.
- The `up`, `migrate/up`, and `migrate/all` commands now prompt to restore the backup created at the outset of the command, or recommend restoring a backup, on failure.
- Added `craft\console\controllers\BackupTrait::restore()`.
- Added `craft\helpers\Component::cleanseConfig()`.
- `craft\log\ContextProcessor::filterVars()` now supports filtering keys using dot notation and `!` negation. ([#13362](https://github.com/craftcms/cms/pull/13362))
- Fixed an error that occurred when passing arguments to an element’s `prev` and `next` fields via GraphQL. ([#13334](https://github.com/craftcms/cms/issues/13334))
- Fixed a bug where Single entries weren’t getting preloaded for template macros, if the template body wasn‘t rendered. ([#13312](https://github.com/craftcms/cms/issues/13312))
- Fixed a bug where asset folders could get dynamically created for elements with temporary slugs. ([#13311](https://github.com/craftcms/cms/issues/13311))
- Fixed a bug where Matrix fields with custom propagation methods were being marked as translatable if the rendered translation key was blank. ([#13329](https://github.com/craftcms/cms/issues/13329))
- Fixed a bug where transformed images’ `width` or `height` properties could be `null` if the transform didn’t specify both dimensions. ([#13335](https://github.com/craftcms/cms/issues/13335))
- Fixed a bug where heading UI elements within field layouts were getting a top border if they were preceeded by conditionally-hidden fields. ([#13308](https://github.com/craftcms/cms/issues/13308))
- Fixed a bug where new Single sections could get URIs filled in on form submit based on the section name, if the input was blank and hadn’t been directly edited. ([#13350](https://github.com/craftcms/cms/issues/13350), [#13355](https://github.com/craftcms/cms/pull/13355))
- Fixed a bug where it was possible to drag items beyond the normal page scroll limits. ([#13351](https://github.com/craftcms/cms/issues/13351))
- Fixed two RCE vulnerabilities.

## 4.4.14 - 2023-06-13

- The `utils/fix-field-layout-uids` command now adds missing field layout component UUIDs.
Expand Down
4 changes: 4 additions & 0 deletions packages/craftcms-sass/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -854,4 +854,8 @@ $radioSize: 16px;
}
}
}

.go:after {
font-size: 14px;
}
}
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.14',
'version' => '4.4.15',
'schemaVersion' => '4.4.0.4',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
29 changes: 29 additions & 0 deletions src/console/controllers/BackupTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,33 @@ private function _backupWarning(): bool
Console::outputWarning('Please backup your database before continuing.');
return $this->confirm('Ready to continue?');
}

/**
* Attempts to restore the database after a migration failure.
*
* @return bool
* @since 4.4.15
*/
protected function restore(): bool
{
if (
!$this->backupPath ||
($this->interactive && !$this->confirm("\nRestore the database backup?", true))
) {
return false;
}

$this->stdout('Restoring the database backup ... ', Console::FG_YELLOW);

try {
Craft::$app->getDb()->restore($this->backupPath);
} catch (Throwable $e) {
$this->stdout('error: ' . $e->getMessage() . PHP_EOL, Console::FG_RED);
$this->stdout('You can manually restore the backup file located at ' . $this->backupPath . PHP_EOL);
return false;
}

$this->stdout('done' . PHP_EOL, Console::FG_GREEN);
return true;
}
}
12 changes: 12 additions & 0 deletions src/console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ public function actionAll(): int
$this->stdout(PHP_EOL . "$applied from $total " . ($applied === 1 ? 'migration was' : 'migrations were') . ' applied.' . PHP_EOL, Console::FG_RED);
$this->stdout(PHP_EOL . 'Migration failed. The rest of the migrations are canceled.' . PHP_EOL, Console::FG_RED);
Craft::$app->disableMaintenanceMode();
Craft::$app->getProjectConfig()->reset();
if (!$this->restore()) {
$this->stdout("\nRestore a database backup before trying again.\n", Console::FG_RED);
}
return ExitCode::UNSPECIFIED_ERROR;
}
$applied++;
Expand Down Expand Up @@ -410,6 +414,14 @@ public function actionUp($limit = 0): int

$res = parent::actionUp($limit);

if ($res === ExitCode::UNSPECIFIED_ERROR) {
Craft::$app->getProjectConfig()->reset();
if (!$this->restore()) {
$this->stdout("\nRestore a database backup before trying again.\n", Console::FG_RED);
}
return $res;
}

if ($res === ExitCode::OK && empty($this->getNewMigrations())) {
// Update any schema versions.
if ($this->track === MigrationManager::TRACK_CRAFT) {
Expand Down
19 changes: 11 additions & 8 deletions src/console/controllers/UpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,26 @@ public function actionIndex(): int
$pendingChanges = Craft::$app->getProjectConfig()->areChangesPending();

// Craft + plugin migrations
if ($this->run('migrate/all', ['noContent' => true]) !== ExitCode::OK) {
$this->stderr("\nAborting remaining tasks.\n", Console::FG_RED);
throw new OperationAbortedException();
$res = $this->run('migrate/all', ['noContent' => true]);
if ($res !== ExitCode::OK) {
$this->stderr("\nAborting remaining tasks.\n", Console::FG_YELLOW);
return $res;
}
$this->stdout("\n");

// Project Config
if ($pendingChanges) {
if ($this->run('project-config/apply') !== ExitCode::OK) {
throw new OperationAbortedException();
$res = $this->run('project-config/apply');
if ($res !== ExitCode::OK) {
return $res;
}
$this->stdout("\n");
}

// Content migrations
if ($this->run('migrate/up', ['track' => MigrationManager::TRACK_CONTENT]) !== ExitCode::OK) {
throw new OperationAbortedException();
// Content migration
$res = $this->run('migrate/up', ['track' => MigrationManager::TRACK_CONTENT]);
if ($res !== ExitCode::OK) {
return $res;
}
$this->stdout("\n");
} catch (Throwable $e) {
Expand Down
30 changes: 1 addition & 29 deletions src/console/controllers/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function actionUpdate(?string $handle = null): int

// Run migrations?
if (!$this->_migrate()) {
if ($this->_restoreDb()) {
if ($this->restore()) {
$this->_revertComposerChanges();
}
return ExitCode::UNSPECIFIED_ERROR;
Expand Down Expand Up @@ -429,34 +429,6 @@ private function _migrate(): bool
return true;
}

/**
* Attempts to restore the database after a migration failure.
*
* @return bool
*/
private function _restoreDb(): bool
{
if (
!$this->backupPath ||
($this->interactive && !$this->confirm('Restore the database backup?', true))
) {
return false;
}

$this->stdout('Restoring the database backup ... ', Console::FG_YELLOW);

try {
Craft::$app->getDb()->restore($this->backupPath);
} catch (Throwable $e) {
$this->stdout('error: ' . $e->getMessage() . PHP_EOL, Console::FG_RED);
$this->stdout('You can manually restore the backup file located at ' . $this->backupPath . PHP_EOL);
return false;
}

$this->stdout('done' . PHP_EOL, Console::FG_GREEN);
return true;
}

/**
* Reverts Composer changes.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/AssetIndexesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ class AssetIndexesController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// No permission no bueno
$this->requirePermission('utility:asset-indexes');
$this->requireAcceptsJson();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/AssetSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ class AssetSettingsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All user settings actions require an admin
$this->requireAdmin();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/BaseElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ abstract class BaseElementsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All actions require control panel requests
$this->requireCpRequest();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
13 changes: 10 additions & 3 deletions src/controllers/ConditionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\conditions\ConditionInterface;
use craft\base\conditions\ConditionRuleInterface;
use craft\helpers\ArrayHelper;
use craft\helpers\Component;
use craft\helpers\Json;
use craft\web\Controller;
use Illuminate\Support\Collection;
Expand All @@ -34,8 +35,14 @@ class ConditionsController extends Controller
*/
public function beforeAction($action): bool
{
$baseConfig = Json::decodeIfJson($this->request->getBodyParam('config'));
$config = $this->request->getBodyParam($baseConfig['name']);
if (!parent::beforeAction($action)) {
return false;
}

$this->requireCpRequest();

$baseConfig = Component::cleanseConfig(Json::decodeIfJson($this->request->getBodyParam('config')));
$config = Component::cleanseConfig($this->request->getBodyParam($baseConfig['name']));
$newRuleType = ArrayHelper::remove($config, 'new-rule-type');
$conditionsService = Craft::$app->getConditions();
$this->_condition = $conditionsService->createCondition($config);
Expand All @@ -48,7 +55,7 @@ public function beforeAction($action): bool
$this->_condition->addConditionRule($rule);
}

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ class FieldsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All field actions require an admin
$this->requireAdmin();

return parent::beforeAction($action);
return true;
}

// Groups
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/FsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ class FsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All asset volume actions require an admin
$this->requireAdmin();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/controllers/GraphqlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ public function beforeAction($action): bool
throw new NotFoundHttpException(Craft::t('yii', 'Page not found.'));
}

Craft::$app->requireEdition(Craft::Pro);

if ($action->id === 'api') {
$this->enableCsrfValidation = false;
}

return parent::beforeAction($action);
if (!parent::beforeAction($action)) {
return false;
}

Craft::$app->requireEdition(Craft::Pro);

return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/ImageTransformsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ class ImageTransformsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All image transform actions require an admin
$this->requireAdmin();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/LivePreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ class LivePreviewController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// Mark this as a Live Preview request
if ($action->id === 'preview') {
$this->request->setIsLivePreview(true);
}

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/PluginStoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ class PluginStoreController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All plugin store actions require an admin
$this->requireAdmin(false);

return parent::beforeAction($action);
return true;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ class PluginsController extends Controller
*/
public function beforeAction($action): bool
{
if (!parent::beforeAction($action)) {
return false;
}

// All plugin actions require an admin
$this->requireAdmin();

return parent::beforeAction($action);
return true;
}

/**
Expand Down
Loading

0 comments on commit 273dfd3

Please sign in to comment.