From d85416c82ef40788873386768f1e83e43761fb47 Mon Sep 17 00:00:00 2001 From: Aron Novak Date: Fri, 15 Nov 2024 18:45:57 +0100 Subject: [PATCH] PHP 8.3 (#734) --- .ddev/config.yaml | 4 +- .travis.yml | 2 +- composer.json | 5 +- composer.lock | 9 ++-- .../server_general/server_general.module | 5 +- .../Plugin/EntityViewBuilder/MediaImage.php | 7 +++ .../EntityViewBuilder/ParagraphSearch.php | 9 ++++ .../Plugin/migrate/process/IframeToMedia.php | 14 ------ .../src/Plugin/migrate/process/ImgToMedia.php | 35 -------------- .../process/MediaEmbedProcessPluginBase.php | 46 ++++++++++++++++--- 10 files changed, 67 insertions(+), 69 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index bbc2880f8..0901b9551 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -1,7 +1,7 @@ name: drupal-starter type: drupal10 docroot: web -php_version: "8.2" +php_version: "8.3" webserver_type: nginx-fpm router_http_port: "8880" router_https_port: "4443" @@ -10,7 +10,7 @@ additional_hostnames: [] additional_fqdns: [] database: type: mariadb - version: "10.5" + version: "10.6" fail_on_hook_fail: true use_dns_when_possible: true composer_version: "2" diff --git a/.travis.yml b/.travis.yml index 197ed414a..ce738b7cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ version: "~> 1.0" language: php dist: jammy php: -- 8.2 +- 8.3 services: - docker stages: diff --git a/composer.json b/composer.json index c846b902f..9b1a3d241 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^8.1", + "php": "^8.3", "ext-curl": "*", "ext-dom": "*", "ext-intl": "*", @@ -131,9 +131,6 @@ "drupal/core-project-message": true, "oomphinc/composer-installers-extender": true, "mglaman/composer-drupal-lenient": true - }, - "platform": { - "php": "8.1" } }, "extra": { diff --git a/composer.lock b/composer.lock index e146533c8..31d558fcc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b39359d82267f4b683b257763dce7b60", + "content-hash": "ab02dbd624e44c5a9609f139707c1f89", "packages": [ { "name": "asm89/stack-cors", @@ -67,7 +67,7 @@ "version": "6.x-dev", "source": { "type": "git", - "url": "git@github.com:FortAwesome/Font-Awesome.git", + "url": "https://github.com/FortAwesome/Font-Awesome.git", "reference": "d02961b018153506364077343b0edcde0a39d27e" }, "dist": { @@ -14950,7 +14950,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^8.1", + "php": "^8.3", "ext-curl": "*", "ext-dom": "*", "ext-intl": "*", @@ -14958,8 +14958,5 @@ "ext-mbstring": "*" }, "platform-dev": {}, - "platform-overrides": { - "php": "8.1" - }, "plugin-api-version": "2.6.0" } diff --git a/web/modules/custom/server_general/server_general.module b/web/modules/custom/server_general/server_general.module index cad3ff5d5..70dfa4d2c 100644 --- a/web/modules/custom/server_general/server_general.module +++ b/web/modules/custom/server_general/server_general.module @@ -183,8 +183,11 @@ function server_general_node_presave(NodeInterface $entity) { // Get the module handler service. $module_handler = \Drupal::service('module_handler'); + if ($entity->isNew()) { + return; + } /** @var \Drupal\node\NodeInterface $original */ - $original = $entity->original; + $original = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($entity->id()); // If content moderation is used, don't allow unpublish for locked pages. if ($module_handler->moduleExists('content_moderation') && $original->get('moderation_state')->getString() === 'published' && $entity->get('moderation_state')->getString() === 'unpublished') { $entity->set('moderation_state', 'published'); diff --git a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/MediaImage.php b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/MediaImage.php index c399089b9..7ac268e23 100644 --- a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/MediaImage.php +++ b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/MediaImage.php @@ -23,6 +23,13 @@ class MediaImage extends EntityViewBuilderPluginAbstract { use ElementMediaTrait; use ElementWrapTrait; + /** + * The iFrame URL helper service. + * + * @var \Drupal\media\IFrameUrlHelper + */ + protected $iFrameUrlHelper; + /** * The responsive image style to use on Hero. */ diff --git a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/ParagraphSearch.php b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/ParagraphSearch.php index 2480e0200..b7e216d17 100644 --- a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/ParagraphSearch.php +++ b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/ParagraphSearch.php @@ -5,6 +5,7 @@ namespace Drupal\server_general\Plugin\EntityViewBuilder; use Drupal\Core\Block\BlockManagerInterface; +use Drupal\Core\Render\RendererInterface; use Drupal\paragraphs\ParagraphInterface; use Drupal\pluggable_entity_view_builder\EntityViewBuilderPluginAbstract; use Drupal\server_general\ElementTrait\SearchTrait; @@ -56,6 +57,13 @@ class ParagraphSearch extends EntityViewBuilderPluginAbstract { */ protected Request $request; + /** + * The renderer service. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected RendererInterface $renderer; + /** * {@inheritdoc} */ @@ -63,6 +71,7 @@ public static function create(ContainerInterface $container, array $configuratio $build = parent::create($container, $configuration, $plugin_id, $plugin_definition); $build->blockManager = $container->get('plugin.manager.block'); $build->request = $container->get('request_stack')->getCurrentRequest(); + $build->renderer = $container->get('renderer'); return $build; } diff --git a/web/modules/custom/server_migrate/src/Plugin/migrate/process/IframeToMedia.php b/web/modules/custom/server_migrate/src/Plugin/migrate/process/IframeToMedia.php index 093adbd3e..4580ee141 100644 --- a/web/modules/custom/server_migrate/src/Plugin/migrate/process/IframeToMedia.php +++ b/web/modules/custom/server_migrate/src/Plugin/migrate/process/IframeToMedia.php @@ -42,20 +42,6 @@ final class IframeToMedia extends MediaEmbedProcessPluginBase implements Contain */ protected $migration; - /** - * The entity type manager service. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** - * The logging service. - * - * @var \Drupal\Core\Logger\LoggerChannelInterface - */ - protected $logger; - /** * Constructor. * diff --git a/web/modules/custom/server_migrate/src/Plugin/migrate/process/ImgToMedia.php b/web/modules/custom/server_migrate/src/Plugin/migrate/process/ImgToMedia.php index 2c6d52f3b..b27bc85e2 100644 --- a/web/modules/custom/server_migrate/src/Plugin/migrate/process/ImgToMedia.php +++ b/web/modules/custom/server_migrate/src/Plugin/migrate/process/ImgToMedia.php @@ -64,41 +64,6 @@ final class ImgToMedia extends MediaEmbedProcessPluginBase implements ContainerF 'www.livedomain.com', ]; - /** - * The entity type manager service. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** - * The logging service. - * - * @var \Drupal\Core\Logger\LoggerChannelInterface - */ - protected $logger; - - /** - * The file system service. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** - * An instance of the download process plugin. - * - * @var \Drupal\migrate\Plugin\MigrateProcessInterface - */ - protected $fileCopyPlugin; - - /** - * The file mime type guesser service. - * - * @var \Symfony\Component\Mime\MimeTypeGuesserInterface - */ - protected MimeTypeGuesserInterface $mimeTypeGuesser; - /** * Constructor. * diff --git a/web/modules/custom/server_migrate/src/Plugin/migrate/process/MediaEmbedProcessPluginBase.php b/web/modules/custom/server_migrate/src/Plugin/migrate/process/MediaEmbedProcessPluginBase.php index d830e2386..13f357ae3 100644 --- a/web/modules/custom/server_migrate/src/Plugin/migrate/process/MediaEmbedProcessPluginBase.php +++ b/web/modules/custom/server_migrate/src/Plugin/migrate/process/MediaEmbedProcessPluginBase.php @@ -4,24 +4,58 @@ namespace Drupal\server_migrate\Plugin\migrate\process; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\File\FileSystemInterface; +use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\file\FileInterface; use Drupal\media\MediaInterface; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; use Masterminds\HTML5; +use Symfony\Component\Mime\MimeTypeGuesserInterface; /** * Base class for migrate process plugins which generate media embeds. - * - * @property \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager - * @property \Drupal\Core\File\FileSystemInterface $fileSystem - * @property \Drupal\migrate\Plugin\MigrateProcessInterface $fileCopyPlugin - * @property \Drupal\Core\Logger\LoggerChannelInterface $logger - * @property \Symfony\Component\Mime\MimeTypeGuesserInterface $mimeTypeGuesser */ abstract class MediaEmbedProcessPluginBase extends ProcessPluginBase { + /** + * Entity Type Manager service. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected EntityTypeManagerInterface $entityTypeManager; + + /** + * File system service. + * + * @var \Drupal\Core\File\FileSystemInterface + */ + protected FileSystemInterface $fileSystem; + + /** + * Migrate transform plugin. + * + * @var \Drupal\migrate\Plugin\MigrateProcessInterface + */ + protected MigrateProcessInterface $fileCopyPlugin; + + /** + * Logger service. + * + * @var \Drupal\Core\Logger\LoggerChannelInterface + */ + protected LoggerChannelInterface $logger; + + /** + * Mime type guesser service. + * + * @var \Symfony\Component\Mime\MimeTypeGuesserInterface + */ + protected MimeTypeGuesserInterface $mimeTypeGuesser; + /** * These are the image extensions that the Image media type accepts. */