Skip to content

Commit

Permalink
Merge branch '5.x' into 5.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/ci.yml
  • Loading branch information
brandonkelly committed Mar 27, 2024
2 parents 841ebe2 + 764e880 commit 548eec8
Show file tree
Hide file tree
Showing 107 changed files with 7,444 additions and 7,695 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- develop
- 5.x
- '5.1'
pull_request:
permissions:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ jobs:

- name: 'Initialize Craft 3 starter project'
if: ${{ startsWith(github.event.client_payload.version, '3.') }}
run: 'composer create-project craftcms/craft=^1 ${{ env.PROJECT_DIRECTORY }}'
run: 'composer create-project craftcms/craft:^3 ${{ env.PROJECT_DIRECTORY }}'

- name: 'Initialize Craft 4 starter project'
if: ${{ startsWith(github.event.client_payload.version, '4.') }}
run: 'composer create-project craftcms/craft ${{ env.PROJECT_DIRECTORY }}'
run: 'composer create-project craftcms/craft:^4 ${{ env.PROJECT_DIRECTORY }}'

- name: 'Initialize Craft 5 starter project'
if: ${{ startsWith(github.event.client_payload.version, '5.') }}
run: 'composer create-project craftcms/craft=^5.0.0-alpha.1 ${{ env.PROJECT_DIRECTORY }}'
run: 'composer create-project craftcms/craft:^5 ${{ env.PROJECT_DIRECTORY }}'

- name: 'Install specific Craft version'
working-directory: ${{ env.PROJECT_DIRECTORY }}
Expand Down
681 changes: 0 additions & 681 deletions CHANGELOG-WIP.md

This file was deleted.

283 changes: 59 additions & 224 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/craftcms-sass/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ $menuBorderRadius: $mediumBorderRadius;
// (sub-pixel antialiasing looks too bold/blurry with light text on dark background)
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-weight: 500;
}

@mixin light-focus-ring() {
Expand Down
2 changes: 1 addition & 1 deletion src/Craft.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Craft extends Yii
/** @deprecated in 5.0.0. [[\craft\enums\CmsEdition::Solo]] should be used instead. */
public const Solo = 0;
/** @deprecated in 5.0.0. [[\craft\enums\CmsEdition::Pro]] should be used instead. */
public const Pro = 1;
public const Pro = 2;

/**
* @var array The default cookie configuration.
Expand Down
8 changes: 8 additions & 0 deletions src/base/PluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace craft\base;

use craft\enums\CmsEdition;

/**
* PluginTrait implements the common methods and properties for plugin classes.
*
Expand Down Expand Up @@ -119,6 +121,12 @@ trait PluginTrait
*/
public string $minVersionRequired = '';

/**
* @var CmsEdition The minimum required Craft CMS edition.
* @since 5.0.0
*/
public CmsEdition $minCmsEdition = CmsEdition::Solo;

/**
* @var string The active edition.
*/
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' => '5.0.0-beta.9',
'version' => '5.0.0',
'schemaVersion' => '5.0.0.20',
'minVersionRequired' => '4.4.0',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
4 changes: 0 additions & 4 deletions src/config/cproutes/pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

return [
'myaccount/permissions' => 'users/permissions',
'users/new' => 'users/create',
'users/<userId:\d+>' => 'users/profile',
'users/<userId:\d+>/addresses' => 'users/addresses',
'users/<userId:\d+>/permissions' => 'users/permissions',
'users/<source:{slug}>' => ['template' => 'users'],
'settings/users' => ['template' => 'settings/users/groups/_index'],
'settings/users/groups/new' => ['template' => 'settings/users/groups/_edit'],
'settings/users/groups/<groupId:\d+>' => ['template' => 'settings/users/groups/_edit'],
Expand Down
8 changes: 8 additions & 0 deletions src/config/cproutes/team.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'users/new' => 'users/create',
'users/<userId:\d+>' => 'users/profile',
'users/<userId:\d+>/addresses' => 'users/addresses',
'users/<source:{slug}>' => ['template' => 'users'],
];
4 changes: 4 additions & 0 deletions src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,10 @@ public function actionRecentActivity(): Response
{
$element = $this->_element();

if ($element instanceof Response) {
return $element;
}

if (!$element || $element->getIsRevision()) {
throw new BadRequestHttpException('No element was identified by the request.');
}
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/PluginStoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function actionIndex(): Response
'edition' => Craft::$app->edition->handle(),
],
'cmsLicenseKey' => App::licenseKey(),
'cmsEditions' => array_map(fn(CmsEdition $edition) => $edition->handle(), CmsEdition::cases()),
'craftIdAccessToken' => $this->getCraftIdAccessToken(),
'phpVersion' => App::phpVersion(),
'composerPhpVersion' => Craft::$app->getComposer()->getConfig()['config']['platform']['php'] ?? null,
Expand Down Expand Up @@ -104,6 +105,7 @@ public function actionCraftData(): Response
$data['canTestEditions'] = Craft::$app->getCanTestEditions();
$data['CraftEdition'] = Craft::$app->edition->value;
$data['CraftSolo'] = CmsEdition::Solo->value;
$data['CraftTeam'] = CmsEdition::Team->value;
$data['CraftPro'] = CmsEdition::Pro->value;

// Logos
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/UserSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function beforeAction($action): bool
$this->requireAdmin();

if ($action->id !== 'save-user-settings') {
Craft::$app->requireEdition(CmsEdition::Pro);
Craft::$app->requireEdition(CmsEdition::Team);
}

return true;
Expand Down Expand Up @@ -141,7 +141,7 @@ public function actionSaveUserSettings(): ?Response
$settings['photoVolumeUid'] = $photoVolumeId ? Craft::$app->getVolumes()->getVolumeById($photoVolumeId)?->uid : null;
$settings['photoSubpath'] = $this->request->getBodyParam('photoSubpath') ?: null;

if (Craft::$app->edition->value >= CmsEdition::Pro->value) {
if (Craft::$app->edition->value >= CmsEdition::Team->value) {
$settings['require2fa'] = $this->request->getBodyParam('require2fa') ?: false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ public function actionActivateUser(): ?Response
*/
public function actionCreate(): Response
{
Craft::$app->requireEdition(CmsEdition::Pro);
Craft::$app->requireEdition(CmsEdition::Team);

$user = Craft::createObject(User::class);

Expand Down Expand Up @@ -1481,7 +1481,7 @@ public function actionSaveUser(): ?Response
}
} else {
// Make sure this is Craft Pro, since that's required for having multiple user accounts
Craft::$app->requireEdition(CmsEdition::Pro);
Craft::$app->requireEdition(CmsEdition::Team);

// Is someone logged in?
if ($currentUser) {
Expand Down
40 changes: 40 additions & 0 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,20 @@ private static function isFolderIndex(): bool
*/
private ?int $_oldVolumeId = null;

/**
* @inheritdoc
*/
public function __construct($config = [])
{
// alt='' actually means something, so we should preserve it.
$alt = ArrayHelper::remove($config, 'alt');
if ($alt !== null) {
$this->alt = $alt;
}

parent::__construct($config);
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -1188,6 +1202,20 @@ public function init(): void
$this->_oldVolumeId = $this->_volumeId;
}

/**
* @inheritdoc
*/
public function setAttributesFromRequest(array $values): void
{
// alt='' actually means something, so we should preserve it.
$alt = ArrayHelper::remove($values, 'alt');
if ($alt !== null) {
$this->alt = $alt;
}

parent::setAttributesFromRequest($values); // TODO: Change the autogenerated stub
}

/**
* Returns the volume’s ID.
*
Expand Down Expand Up @@ -2605,6 +2633,18 @@ protected function attributeHtml(string $attribute): string
return parent::attributeHtml($attribute);
}

/**
* @inheritdoc
*/
public function getInlineAttributeInputHtml(string $attribute): string
{
if ($this->isFolder) {
return '';
}

return parent::getInlineAttributeInputHtml($attribute);
}

/**
* Returns the HTML for asset previews.
*
Expand Down
34 changes: 33 additions & 1 deletion src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,18 @@ protected function defineRules(): array
'required',
'when' => fn() => !isset($this->fieldId),
];
$rules[] = [
['typeId'],
function(string $attribute) {
if (!$this->isEntryTypeAllowed()) {
$this->addError($attribute, Craft::t('app', '{type} entries are no longer allowed in this section. Please choose a different entry type.', [
'type' => $this->getType()->getUiLabel(),
]));
}
},
'skipOnEmpty' => false,
'when' => fn() => $this->getIsCanonical(),
];
$rules[] = [['fieldId'], function(string $attribute) {
if (isset($this->sectionId)) {
$this->addError($attribute, Craft::t('app', '`sectionId` and `fieldId` cannot both be set on an entry.'));
Expand Down Expand Up @@ -1934,7 +1946,10 @@ public function metaFieldsHtml(bool $static): string
// Type
$fields[] = (function() use ($static) {
$entryTypes = $this->getAvailableEntryTypes();
if (count($entryTypes) <= 1) {
if (!ArrayHelper::contains($entryTypes, fn(EntryType $entryType) => $entryType->id === $this->typeId)) {
$entryTypes[] = $this->getType();
}
if (count($entryTypes) <= 1 && $this->isEntryTypeAllowed($entryTypes)) {
return null;
}

Expand Down Expand Up @@ -2570,4 +2585,21 @@ private function _shouldSaveRevision(): bool
$this->getSection()?->enableVersioning
);
}

/**
* Check if current typeId is in the array of passed in entry types.
* If no entry types are passed, check get all the available ones.
*
* @param array|null $entryTypes
* @return bool
* @throws InvalidConfigException
*/
private function isEntryTypeAllowed(array|null $entryTypes = null): bool
{
if ($entryTypes === null) {
$entryTypes = $this->getAvailableEntryTypes();
}

return in_array($this->typeId, array_map(fn($entryType) => $entryType->id, $entryTypes));
}
}
Loading

0 comments on commit 548eec8

Please sign in to comment.