Skip to content

Commit d44ce85

Browse files
committed
Merge branch 'fix_deprecations'
2 parents 192c5fc + 12f4a36 commit d44ce85

5 files changed

Lines changed: 28 additions & 9 deletions

File tree

.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ DISABLE_YEAR2038_BUG_CHECK=0
149149
#TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
150150
#TRUSTED_HOSTS='^(localhost|example\.com)$'
151151

152+
###################################################################################
153+
# Logging settings
154+
###################################################################################
155+
156+
# The minimum level a deprecation notice must have to be written to the var/log/<env>_deprecations.log file.
157+
# Deprecation notices are logged with level "info", so this disables the deprecation log by default.
158+
# Set to debug to log all deprecation notices
159+
DEPRECATION_LOG_LEVEL=emergency
160+
161+
152162

153163
###> symfony/lock ###
154164
# Choose one of the stores below

config/packages/monolog.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ when@prod:
5151
type: stream
5252
channels: [deprecation]
5353
path: "%kernel.logs_dir%/%kernel.environment%_deprecations.log"
54+
level: "%env(DEPRECATION_LOG_LEVEL)%"
5455

5556
when@docker:
5657
monolog:
@@ -75,3 +76,4 @@ when@docker:
7576
type: stream
7677
channels: [deprecation]
7778
path: "%kernel.logs_dir%/%kernel.environment%_deprecations.log"
79+
level: "%env(DEPRECATION_LOG_LEVEL)%"

docs/configuration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,13 @@ See the [information providers]({% link usage/information_provider_system.md %})
279279
* `BANNER`: You can configure the text that should be shown as the banner on the homepage. Useful especially for docker
280280
containers. In all other applications you can just change the `config/banner.md` file.
281281
* `DISABLE_YEAR2038_BUG_CHECK` (env only): If set to `1`, the year 2038 bug check is disabled on 32-bit systems, and dates after
282-
2038 are no longer forbidden. However this will lead to 500 error messages when rendering dates after 2038 as all current
282+
2038 are no longer forbidden. However, this will lead to 500 error messages when rendering dates after 2038 as all current
283283
32-bit PHP versions can not format these dates correctly. This setting is for the case that future PHP versions will
284284
handle this correctly on 32-bit systems. 64-bit systems are not affected by this bug, and the check is always disabled.
285+
* `DEPRECATION_LOG_LEVEL` (default `emergency`) (env only): In the `prod` and `docker` environments, PHP/Symfony
286+
deprecation notices are written to their own `var/log/<env>_deprecations.log` file. This option sets the minimum log
287+
level a deprecation notice must have to be written there. Since deprecation notices are logged with level `info`,
288+
the default value of `emergency` effectively disables this dedicated deprecation log. Set it to `debug` to enable it.
285289

286290
## Banner
287291

src/Controller/TreeController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
namespace App\Controller;
2424

25+
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
2526
use Symfony\Component\HttpFoundation\Response;
2627
use App\Entity\ProjectSystem\Project;
2728
use App\Entity\Parts\Category;
@@ -55,7 +56,7 @@ public function tools(ToolsTreeBuilder $builder): JsonResponse
5556

5657
#[Route(path: '/category/{id}', name: 'tree_category')]
5758
#[Route(path: '/categories', name: 'tree_category_root')]
58-
public function categoryTree(?Category $category = null): JsonResponse
59+
public function categoryTree(#[MapEntity(id: 'id')] ?Category $category = null): JsonResponse
5960
{
6061
if ($this->isGranted('@parts.read') && $this->isGranted('@categories.read')) {
6162
$tree = $this->treeGenerator->getTreeView(Category::class, $category, 'list_parts_root');
@@ -68,7 +69,7 @@ public function categoryTree(?Category $category = null): JsonResponse
6869

6970
#[Route(path: '/footprint/{id}', name: 'tree_footprint')]
7071
#[Route(path: '/footprints', name: 'tree_footprint_root')]
71-
public function footprintTree(?Footprint $footprint = null): JsonResponse
72+
public function footprintTree(#[MapEntity(id: 'id')] ?Footprint $footprint = null): JsonResponse
7273
{
7374
if ($this->isGranted('@parts.read') && $this->isGranted('@footprints.read')) {
7475
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint, 'list_parts_root');
@@ -80,7 +81,7 @@ public function footprintTree(?Footprint $footprint = null): JsonResponse
8081

8182
#[Route(path: '/location/{id}', name: 'tree_location')]
8283
#[Route(path: '/locations', name: 'tree_location_root')]
83-
public function locationTree(?StorageLocation $location = null): JsonResponse
84+
public function locationTree(#[MapEntity(id: 'id')] ?StorageLocation $location = null): JsonResponse
8485
{
8586
if ($this->isGranted('@parts.read') && $this->isGranted('@storelocations.read')) {
8687
$tree = $this->treeGenerator->getTreeView(StorageLocation::class, $location, 'list_parts_root');
@@ -93,7 +94,7 @@ public function locationTree(?StorageLocation $location = null): JsonResponse
9394

9495
#[Route(path: '/manufacturer/{id}', name: 'tree_manufacturer')]
9596
#[Route(path: '/manufacturers', name: 'tree_manufacturer_root')]
96-
public function manufacturerTree(?Manufacturer $manufacturer = null): JsonResponse
97+
public function manufacturerTree(#[MapEntity(id: 'id')] ?Manufacturer $manufacturer = null): JsonResponse
9798
{
9899
if ($this->isGranted('@parts.read') && $this->isGranted('@manufacturers.read')) {
99100
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer, 'list_parts_root');
@@ -106,7 +107,7 @@ public function manufacturerTree(?Manufacturer $manufacturer = null): JsonRespon
106107

107108
#[Route(path: '/supplier/{id}', name: 'tree_supplier')]
108109
#[Route(path: '/suppliers', name: 'tree_supplier_root')]
109-
public function supplierTree(?Supplier $supplier = null): JsonResponse
110+
public function supplierTree(#[MapEntity(id: 'id')] ?Supplier $supplier = null): JsonResponse
110111
{
111112
if ($this->isGranted('@parts.read') && $this->isGranted('@suppliers.read')) {
112113
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier, 'list_parts_root');
@@ -119,7 +120,7 @@ public function supplierTree(?Supplier $supplier = null): JsonResponse
119120

120121
#[Route(path: '/device/{id}', name: 'tree_device')]
121122
#[Route(path: '/devices', name: 'tree_device_root')]
122-
public function deviceTree(?Project $device = null): JsonResponse
123+
public function deviceTree(#[MapEntity(id: 'id')] ?Project $device = null): JsonResponse
123124
{
124125
if ($this->isGranted('@projects.read')) {
125126
$tree = $this->treeGenerator->getTreeView(Project::class, $device, 'devices');

src/Doctrine/Middleware/SetSQLModeMiddlewareDriver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public function connect(array $params): Connection
3535
{
3636
//Only set this on MySQL connections, as other databases don't support this parameter
3737
if($params['driver'] === 'pdo_mysql') {
38-
//1002 is \PDO::MYSQL_ATTR_INIT_COMMAND constant value
39-
$params['driverOptions'][\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode, \'ONLY_FULL_GROUP_BY\', \'\'))';
38+
//PDO::MYSQL_ATTR_INIT_COMMAND is deprecated since PHP 8.5 in favor of Pdo\Mysql::ATTR_INIT_COMMAND,
39+
//but the Pdo\Mysql class only exists since PHP 8.4. Both constants have the same value (1002).
40+
$initCommandAttr = class_exists(\Pdo\Mysql::class) ? \Pdo\Mysql::ATTR_INIT_COMMAND : \PDO::MYSQL_ATTR_INIT_COMMAND;
41+
$params['driverOptions'][$initCommandAttr] = 'SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode, \'ONLY_FULL_GROUP_BY\', \'\'))';
4042
}
4143

4244
return parent::connect($params);

0 commit comments

Comments
 (0)