Skip to content

Commit 2d8030d

Browse files
committed
Manual merge
2 parents 1e74099 + 6f40075 commit 2d8030d

File tree

21 files changed

+437
-100
lines changed

21 files changed

+437
-100
lines changed

.github/ISSUE_TEMPLATE/1_BUG_REPORT.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ body:
2727
label: PHP Version
2828
description: Please provide us the branch of PHP version. For example, for PHP version 7.4.9, select `7.4`, or for PHP version 8.0.1, select `8.0`.
2929
options:
30+
- 8.4
31+
- 8.3
32+
- 8.2
3033
- 8.1
3134
- 8.0
3235
- 7.4

.github/workflows/code-quality.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install PHP and PHP Code Sniffer
2828
uses: shivammathur/setup-php@v2
2929
with:
30-
php-version: 8.0
30+
php-version: 8.2
3131
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
3232
tools: phpcs
3333

.github/workflows/manifest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Update manifest
1212
runs-on: ubuntu-latest
1313
env:
14-
phpVersion: '8.1'
14+
phpVersion: '8.2'
1515
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
1616
key: winter-cms-cache-develop
1717
steps:

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: ${{ matrix.operatingSystem }} / JavaScript
1919
env:
2020
nodeVersion: 16
21-
phpVersion: '8.0'
21+
phpVersion: '8.2'
2222
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
2323
key: winter-cms-cache-develop
2424
steps:
@@ -96,7 +96,7 @@ jobs:
9696
max-parallel: 8
9797
matrix:
9898
operatingSystem: [ubuntu-latest, windows-latest]
99-
phpVersion: ['8.0', '8.1', '8.2', '8.3']
99+
phpVersion: ['8.1', '8.2', '8.3', '8.4']
100100
fail-fast: false
101101
runs-on: ${{ matrix.operatingSystem }}
102102
name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }}

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"source": "https://github.com/wintercms/winter"
3030
},
3131
"require": {
32-
"php": "^8.0.2",
33-
"winter/storm": "dev-wip/support-uploading-packages-update-manager-changes as 1.2",
32+
"php": ">=8.1",
33+
"winter/storm": "dev-develop as 1.2",
3434
"winter/wn-system-module": "dev-develop",
3535
"winter/wn-backend-module": "dev-develop",
3636
"winter/wn-cms-module": "dev-develop",

modules/backend/behaviors/UserPreferencesModel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use System\Behaviors\SettingsModel;
44
use Backend\Models\UserPreference;
5+
use Winter\Storm\Database\Model;
56

67
/**
78
* User Preferences model extension, identical to System\Behaviors\SettingsModel
@@ -58,9 +59,8 @@ public function isConfigured(): bool
5859

5960
/**
6061
* Returns the raw Model record that stores the settings.
61-
* @return Model
6262
*/
63-
public function getSettingsRecord()
63+
public function getSettingsRecord(): ?Model
6464
{
6565
$item = UserPreference::forUser();
6666
$record = $item

modules/backend/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
],
2525
"require": {
26-
"php": "^8.0.2",
26+
"php": ">=8.1",
2727
"composer/installers": "~1.11.0",
2828
"laravel/framework": "^9.1"
2929
},

modules/backend/formwidgets/ColorPicker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ColorPicker extends FormWidgetBase
6464
*/
6565
protected array $validationPatterns = [
6666
'cmyk' => '/^cmyk\((\d{1,2}\.?\d{0,2}%,? ?){4}\)$/',
67-
'hex' => '/^#[\w\d]{6}$/',
67+
'hex' => '/^#[\w\d]{6,8}$/',
6868
'hsl' => '/^hsla\((\d{1,3}\.?\d{0,2}%?, ?){3}\d\.?\d{0,2}?\)$/',
6969
'rgb' => '/^rgba\((\d{1,3}\.?\d{0,2}, ?){3}\d\.?\d{0,2}?\)$/',
7070
];

modules/backend/lang/ru/lang.php

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
],
313313
'recordfinder' => [
314314
'find_record' => 'Найти запись',
315+
'default_prompt' => 'Нажмите кнопку %s чтобы найти запись',
315316
'invalid_model_class' => 'Предоставленный класс модели ":modelClass" для поиска записи является недействительным',
316317
'cancel' => 'Отмена',
317318
],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* @var \Winter\Storm\Database\Model $formModel
4+
* @var \Backend\Classes\FormField $field
5+
*/
6+
$action = 'button';
7+
$handler = null;
8+
$href = null;
9+
$target = null;
10+
11+
if (!empty($field->config['href']) || filter_var($field->value, FILTER_VALIDATE_URL)) {
12+
$action = 'link';
13+
$href = $field->config['href'] ?? '';
14+
$target = $field->config['target'] ?? null;
15+
if ($formModel->hasAttribute($href)) {
16+
$href = $formModel->getAttribute($href);
17+
}
18+
if (filter_var($field->value, FILTER_VALIDATE_URL)) {
19+
$href = $field->value;
20+
}
21+
} elseif (!empty($field->config['handler'])) {
22+
$action = 'popup';
23+
$handler = $field->config['handler'];
24+
}
25+
26+
$element = $action === 'link' ? 'a' : 'button';
27+
$label = $field->config['buttonLabel'] ?? '';
28+
$buttonType = $field->config['buttonType'] ?? 'default';
29+
$classes = implode(' ', array_filter([
30+
"btn btn-$buttonType",
31+
$field->config['buttonCssClass'] ?? ''
32+
]));
33+
$request = $field->config['request'] ?? '';
34+
35+
$loadingText = $field->config['loading'] ?? '';
36+
$icon = $field->config['icon'] ?? '';
37+
?>
38+
<div class="loading-indicator-container">
39+
<?php if ($field->path): ?>
40+
<?= $this->controller->makePartial($field->path, [
41+
'formWidget' => $this,
42+
'formModel' => $formModel,
43+
'formField' => $field,
44+
'formValue' => $field->value,
45+
'model' => $formModel,
46+
'field' => $field,
47+
'value' => $field->value,
48+
'action' => $action,
49+
'element' => $element,
50+
'label' => $label,
51+
'buttonType' => $buttonType,
52+
'classes' => $classes,
53+
'handler' => $handler,
54+
'request' => $request,
55+
'href' => $href,
56+
'target' => $target,
57+
'loading' => $loadingText,
58+
'icon' => $icon,
59+
]) ?>
60+
<?php else: ?>
61+
<<?= e($element); ?>
62+
class="<?= e($classes); ?>"
63+
data-load-indicator<?= !empty($loadingText) ? '="' . e(trans($loadingText)) . '"' : ''; ?>
64+
<?= $action === 'popup' ? 'data-control="popup"' : ''; ?>
65+
<?= !empty($handler) ? 'data-handler="' . e($handler) . '"' : ''; ?>
66+
<?= !empty($request) ? 'data-request="' . e($request) . '"' : ''; ?>
67+
<?= !empty($href) ? 'href="' . e($href) . '"' : ''; ?>
68+
<?= !empty($target) ? 'target="' . e($target) . '"' : ''; ?>
69+
>
70+
<?= !empty($icon) ? '<i class="' . e($icon) . '"></i>' : '' ?>
71+
<?= e(trans($label)); ?>
72+
</<?= e($element); ?>>
73+
<?php endif; ?>
74+
</div>

modules/cms/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
],
2525
"require": {
26-
"php": "^8.0.2",
26+
"php": ">=8.1",
2727
"composer/installers": "~1.11.0",
2828
"laravel/framework": "^9.1"
2929
},

modules/cms/lang/ru/lang.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
return [
44
'cms_object' => [
5-
'invalid_file' => 'Ошибка в имени файла: :name. Имена файлов могут содержать только латинские буквы, цифры, знаки подчеркивания и точки. Пример правильных имен файлов: page.htm, page, subdirectory/page',
5+
'invalid_file' => 'Ошибка в имени файла: :name. Имена файлов могут содержать только латинские буквы, цифры, знаки подчеркивания и точки. Пример правильных имён файлов: page.htm, page, subdirectory/page',
66
'invalid_property' => "Параметр ':name' нельзя изменить.",
77
'file_already_exists' => "Файл ':name' уже существует.",
88
'error_saving' => "Ошибка сохранения файла ':name'. Пожалуйста, проверьте права на запись.",
99
'error_creating_directory' => 'Ошибка создания директории :name. Пожалуйста, проверьте права на запись.',
10-
'invalid_file_extension' => 'Указано неправильное расширение файла: :invalid. Разрешенные расширения: :allowed.',
10+
'invalid_file_extension' => 'Указано неправильное расширение файла: :invalid. Разрешённые расширения: :allowed.',
1111
'error_deleting' => "Невозможно удалить файл шаблона ':name'. Пожалуйста, проверьте права на запись.",
1212
'delete_success' => 'Шаблоны были успешно удалены: :count.',
1313
'file_name_required' => 'Пожалуйста, укажите имя файла шаблона.',
@@ -76,7 +76,7 @@
7676
'export_button' => 'Экспортировать',
7777
'export_title' => 'Экспортировать тему',
7878
'export_folders_label' => 'Папки',
79-
'export_folders_comment' => 'Пожалуйста, выберите папки темы, которые вы хотели бы экспортировать',
79+
'export_folders_comment' => 'Пожалуйста, выберите папки темы которые вы хотели бы экспортировать',
8080
'delete_button' => 'Удалить',
8181
'delete_confirm' => 'Вы уверены, что хотите удалить эту тему? Это действие необратимо!',
8282
'delete_active_theme_failed' => 'Невозможно удалить активный тему, попробуйте сделать другую тему активной.',
@@ -90,10 +90,10 @@
9090
'new_directory_name_comment' => 'Укажите новое имя каталога для дубликата темы.',
9191
'dir_name_invalid' => 'Имя может содержать только цифры, латинские буквы и следующие символы: _ -',
9292
'dir_name_taken' => 'Указанный каталог уже существует.',
93-
'find_more_themes' => 'Найти еще темы',
93+
'find_more_themes' => 'Найти ещё темы',
9494
'saving' => 'Сохранение темы...',
9595
'return' => 'Вернуться к списку тем',
96-
'default_description' => 'Пользовательская тема сгенерированая для :url',
96+
'default_description' => 'Пользовательская тема сгенерированная для :url',
9797
'scaffold' => [
9898
'label' => 'Каркас',
9999
'empty' => 'Пусто',

modules/cms/models/MaintenanceSetting.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function afterFetch()
8282
{
8383
if (
8484
($theme = Theme::getEditTheme())
85-
&& ($themeMap = array_get($this->attributes, 'theme_map'))
85+
&& ($themeMap = array_get($this->value, 'theme_map'))
8686
&& ($cmsPage = array_get($themeMap, $theme->getDirName()))
8787
) {
8888
$this->cms_page = $cmsPage;
@@ -100,6 +100,6 @@ public function afterFetch()
100100
*/
101101
public static function isAllowedIp(string $ip): bool
102102
{
103-
return IpUtils::checkIp($ip, Arr::pluck(static::get('allowed_ips', []), 'ip'));
103+
return IpUtils::checkIp($ip, Arr::pluck(static::get('allowed_ips', []) ?? [], 'ip'));
104104
}
105105
}

modules/system/ServiceProvider.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,23 @@ protected function registerErrorHandler()
381381
protected function registerLogging()
382382
{
383383
Event::listen(\Illuminate\Log\Events\MessageLogged::class, function ($event) {
384+
if (!EventLog::useLogging()) {
385+
return;
386+
}
387+
388+
$details = $event->context ?? null;
389+
390+
// This allows for preventing db logging in cases where we don't want all log messages logged to the DB.
391+
if (isset($details['skipDatabaseLog']) && $details['skipDatabaseLog']) {
392+
return;
393+
}
394+
395+
EventLog::add($event->message, $event->level, $details);
396+
});
397+
398+
Event::listen('exception.report', function (\Throwable $throwable) {
384399
if (EventLog::useLogging()) {
385-
$details = $event->context ?? null;
386-
EventLog::add($event->message, $event->level, $details);
400+
EventLog::addException($throwable);
387401
}
388402
});
389403
}

modules/system/behaviors/SettingsModel.php

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php namespace System\Behaviors;
22

3-
use App;
4-
use Artisan;
5-
use Cache;
6-
use Log;
73
use Exception;
84
use Illuminate\Database\QueryException;
5+
use Illuminate\Support\Facades\App;
6+
use Illuminate\Support\Facades\Artisan;
7+
use Illuminate\Support\Facades\Cache;
8+
use Illuminate\Support\Facades\Log;
99
use System\Classes\ModelBehavior;
10+
use Winter\Storm\Database\Model;
1011

1112
/**
1213
* Settings model extension
@@ -112,30 +113,35 @@ public function resetDefault()
112113
*/
113114
public function isConfigured(): bool
114115
{
115-
return App::hasDatabase() && $this->getSettingsRecord() !== null;
116+
if (!App::hasDatabase()) {
117+
return false;
118+
}
119+
120+
$record = null;
121+
try {
122+
$record = $this->getSettingsRecord();
123+
} catch (QueryException $ex) {
124+
// SQLSTATE[42S02]: Base table or view not found - migrations haven't run yet
125+
if ($ex->getCode() !== '42S02') {
126+
Log::error($ex, ['skipDatabaseLog' => true]);
127+
}
128+
}
129+
130+
return $record !== null;
116131
}
117132

118133
/**
119134
* Returns the raw Model record that stores the settings.
120-
* @return Model
121135
*/
122-
public function getSettingsRecord()
136+
public function getSettingsRecord(): ?Model
123137
{
124138
$query = $this->model->where('item', $this->recordCode);
125139

126140
if ($this->cacheTtl > 0) {
127141
$query = $query->remember($this->cacheTtl, $this->getCacheKey());
128142
}
129143

130-
$record = null;
131-
try {
132-
$record = $query->first();
133-
} catch (QueryException $ex) {
134-
// SQLSTATE[42S02]: Base table or view not found - migrations haven't run yet
135-
if ($ex->getCode() === '42S02') {
136-
traceLog($ex);
137-
}
138-
}
144+
$record = $query->first();
139145

140146
return $record ?: null;
141147
}

modules/system/classes/extensions/PluginManager.php

+19-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use FilesystemIterator;
77
use Illuminate\Console\View\Components\Error;
88
use Illuminate\Console\View\Components\Info;
9+
use Illuminate\Database\QueryException;
910
use Illuminate\Support\Facades\App;
1011
use Illuminate\Support\Facades\Artisan;
1112
use Illuminate\Support\Facades\Cache;
@@ -652,8 +653,15 @@ public function registerAll(bool $force = false): void
652653
return;
653654
}
654655

655-
foreach ($this->plugins as $pluginId => $plugin) {
656-
$this->registerPlugin($plugin, $pluginId);
656+
try {
657+
foreach ($this->plugins as $pluginId => $plugin) {
658+
$this->registerPlugin($plugin, $pluginId);
659+
}
660+
} catch (QueryException $ex) {
661+
// SQLSTATE[42S02]: Base table or view not found - migrations haven't run yet
662+
if ($ex->getCode() === '42S02') {
663+
Log::error("$pluginId cannot be registered, missing database content. Try running migrations. Error: " . $ex->getMessage());
664+
}
657665
}
658666

659667
// Ensure that route attributes are properly loaded
@@ -768,8 +776,15 @@ public function bootAll(bool $force = false): void
768776
return;
769777
}
770778

771-
foreach ($this->plugins as $plugin) {
772-
$this->bootPlugin($plugin);
779+
try {
780+
foreach ($this->plugins as $pluginId => $plugin) {
781+
$this->bootPlugin($plugin);
782+
}
783+
} catch (QueryException $ex) {
784+
// SQLSTATE[42S02]: Base table or view not found - migrations haven't run yet
785+
if ($ex->getCode() === '42S02') {
786+
Log::error("$pluginId cannot be booted, missing database content. Try running migrations. Error: " . $ex->getMessage());
787+
}
773788
}
774789

775790
$this->booted = true;

modules/system/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
],
2525
"require": {
26-
"php": "^8.0.2",
26+
"php": ">=8.1",
2727
"composer/installers": "~1.11.0",
2828
"laravel/framework": "^9.1",
2929
"composer/semver": "^3.2"

0 commit comments

Comments
 (0)