Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-4991: Ensure PHP8.3 compatibility. #644

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ services:
- COMPOSERVER=--2
- DOCUMENT_ROOT=/test/oe_content
mysql:
image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/percona:5.7
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3
image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/percona:8.0
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 --skip-log-bin --innodb-flush-log-at-trx-commit=2 --innodb-read-io-threads=16 --innodb-write-io-threads=16
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
sparql:
Expand Down Expand Up @@ -103,22 +103,22 @@ pipeline:

matrix:
include:
- { PHP_VERSION: 8.1, CORE_VERSION: 10.2.0, TYPE: phpunit }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch3' }

- { PHP_VERSION: 8.2, CORE_VERSION: 10.2.0, TYPE: phpunit }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.2.0, TYPE: behat, BATCH: '@batch3' }

- { PHP_VERSION: 8.1, CORE_VERSION: 10.3.0, TYPE: phpunit }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch3' }

- { PHP_VERSION: 8.2, CORE_VERSION: 10.3.0, TYPE: phpunit }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.2, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch3' }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.3.0, TYPE: phpunit }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.3.0, TYPE: behat, BATCH: '@batch3' }

- { PHP_VERSION: 8.1, CORE_VERSION: 10.4.0, TYPE: phpunit }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.1, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch3' }

- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: phpunit }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch1' }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch2' }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: behat, BATCH: '@batch3' }
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"mikey179/vfsstream": "^1.6",
"nikic/php-parser": "^4.18",
"openeuropa/behat-transformation-context": "~0.2",
"openeuropa/code-review": "^2.0",
"openeuropa/code-review-drupal": "^1.0.0-alpha",
"openeuropa/oe_corporate_countries": "^2.0.0-alpha6",
"openeuropa/oe_corporate_site_info": "^1.0",
"openeuropa/oe_link_lists": "~0.21",
"openeuropa/oe_multilingual": "^1.18",
"openeuropa/oe_time_caching": "^1.5",
"openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta6",
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"openeuropa/task-runner-ensure-behat-batching": "^1.0",
"phpspec/prophecy-phpunit": "^2",
"symfony/phpunit-bridge": "^6.0"
Expand Down Expand Up @@ -70,6 +70,14 @@
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "git",
"url": "https://github.com/openeuropa/DrupalDriver.git"
},
{
"type": "git",
"url": "https://github.com/openeuropa/code-review-drupal.git"
}
],
"extra": {
Expand Down Expand Up @@ -112,6 +120,7 @@
"drupal/core-composer-scaffold": true,
"enable-patching": true,
"phpro/grumphp": true,
"phpro/grumphp-shim": true,
"phpstan/extension-installer": true
}
}
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '2'
services:
web:
image: fpfis/httpd-php-dev:8.2
image: fpfis/httpd-php-dev:8.3
working_dir: /var/www/html
ports:
- 8080:8080
Expand All @@ -17,8 +16,8 @@ services:
# Enable step debugging for all PHP request. See ./README.md#step-debugging for more information.
#XDEBUG_SESSION: 1
mysql:
image: percona/percona-server:5.7
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3
image: percona/percona-server:8.0
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 --skip-log-bin --innodb-flush-log-at-trx-commit=2 --innodb-read-io-threads=16 --innodb-write-io-threads=16
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# ports:
Expand Down
36 changes: 6 additions & 30 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
imports:
- { resource: vendor/openeuropa/code-review/dist/drupal-conventions.yml }

- { resource: ./vendor/openeuropa/code-review-drupal/dist/oe-component-conventions.yml }
grumphp:
tasks:
phpparser:
ignore_patterns:
- vendor/
git_hook_variables:
EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web'
extensions:
- OpenEuropa\CodeReview\ExtraTasksExtension

parameters:
tasks.phpcs.ignore_patterns:
- build/
- node_modules/
- vendor/
tasks.phpcs.triggered_by:
- php
- module
- inc
- theme
- install
- yml

extra_tasks:
phpparser:
ignore_patterns:
- build/
- node_modules/
- vendor/
visitors:
declare_strict_types: ~
triggered_by:
- php
- module
- inc
- theme
- install
tasks.phpstan.configuration: phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class CallProposalsDeadlineDateValidator extends ConstraintValidator {
* {@inheritdoc}
*/
public function validate($node, Constraint $constraint) {
/** @var \Drupal\node\NodeInterface $node */
if (!isset($node) || $node->getType() !== 'oe_call_proposals') {
return;
}

/** @var \Drupal\node\NodeInterface $node */
$wrapper = CallForProposalsNodeWrapper::getInstance($node);

$deadline_model = $wrapper->getModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function setUp(): void {
$this->installEntitySchema('node');
$this->installEntitySchema('media');
$this->installEntitySchema('entity_test');
module_load_include('install', 'oe_content_documents_field');
$this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install');
oe_content_documents_field_install(FALSE);
$this->installConfig([
'field',
Expand All @@ -69,7 +69,7 @@ protected function setUp(): void {
'oe_content_social_media_links_field',
'oe_content_call_proposals',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function setUp(): void {
$this->installEntitySchema('node');
$this->installEntitySchema('media');
$this->installEntitySchema('entity_test');
module_load_include('install', 'oe_content_documents_field');
$this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install');
oe_content_documents_field_install(FALSE);
$this->installConfig([
'field',
Expand All @@ -67,7 +67,7 @@ protected function setUp(): void {
'oe_content_social_media_links_field',
'oe_content_call_tenders',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function setUp(): void {
'oe_content_departments_field',
'oe_content_consultation',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
1 change: 1 addition & 0 deletions modules/oe_content_entity/oe_content_entity.module
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function oe_content_entity_default_preprocess(array &$variables, string $hook):
function oe_content_entity_default_theme_suggestion(array &$variables, string $hook): array {
// We assume that the entity name and the theme hook are the same.
$entity_key = '#' . $hook;
$entity = NULL;
if (isset($variables['elements'][$entity_key])) {
$entity = $variables['elements'][$entity_key];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function setUp(): void {
'oe_content_person',
'oe_content_event_person_reference',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class EventFieldsRequiredValidator extends ConstraintValidator {
* {@inheritdoc}
*/
public function validate($node, Constraint $constraint) {
/** @var \Drupal\node\NodeInterface $node */
if (!isset($node) || $node->getType() !== 'oe_event') {
return;
}

/** @var \Drupal\node\NodeInterface $node */
$this->validateRegistrationGroupFields($constraint, $node);

$online_required_fields = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function setUp(): void {
'oe_content_social_media_links_field',
'oe_content_event',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ protected function formElementItemsEntities(FieldItemListInterface $items, int $
// Determine if we're submitting and if submit came from this widget.
$is_relevant_submit = FALSE;
$triggering_element = $form_state->getTriggeringElement();
$field_name_key = 2;
if ($triggering_element) {
$last_parent = end($triggering_element['#parents']);
if (in_array($last_parent, [
Expand All @@ -363,7 +364,7 @@ protected function formElementItemsEntities(FieldItemListInterface $items, int $
$is_relevant_submit &= ($triggering_element['#parents'][$field_name_key] === $this->fieldDefinition->getName()) &&
(array_slice($triggering_element['#parents'], 0, count($element['#field_parents'])) == $element['#field_parents']);
}
};
}

if ($is_relevant_submit) {
// Submit was triggered by hidden "target_id" element when entities were
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void {
'oe_content_organisation',
'rdf_skos',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
19 changes: 16 additions & 3 deletions modules/oe_content_persistent/src/Plugin/Filter/FilterPurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\Error;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Drupal\oe_content_persistent\ContentUrlResolverInterface;
use Drupal\oe_content_persistent\ContentUuidResolverInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down Expand Up @@ -57,6 +59,13 @@ class FilterPurl extends FilterBase implements ContainerFactoryPluginInterface {
*/
protected $siteConfig;

/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;

/**
* Constructs a new FilterPurl object.
*
Expand All @@ -72,13 +81,16 @@ class FilterPurl extends FilterBase implements ContainerFactoryPluginInterface {
* The content UUID resolver service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Psr\Log\LoggerInterface|null $logger
* A logger instance.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContentUrlResolverInterface $url_resolver, ContentUuidResolverInterface $uuid_resolver, ConfigFactoryInterface $config_factory) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContentUrlResolverInterface $url_resolver, ContentUuidResolverInterface $uuid_resolver, ConfigFactoryInterface $config_factory, ?LoggerInterface $logger = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->contentUrlResolver = $url_resolver;
$this->contentUuidResolver = $uuid_resolver;
$this->purlConfig = $config_factory->get('oe_content_persistent.settings');
$this->siteConfig = $config_factory->get('system.site');
$this->logger = $logger;
}

/**
Expand All @@ -91,7 +103,8 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_definition,
$container->get('oe_content_persistent.url_resolver'),
$container->get('oe_content_persistent.uuid_resolver'),
$container->get('config.factory')
$container->get('config.factory'),
$container->get('logger.factory')->get('filter_purl')
);
}

Expand Down Expand Up @@ -144,7 +157,7 @@ public function process($text, $langcode) {
$result->addCacheableDependency($url);
}
catch (\Exception $e) {
watchdog_exception('filter_purl', $e);
Error::logException($this->logger, $e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function buildDescription(EntityInterface $entity) {
],
];
$thumbnail = $entity->thumbnail->view($thumbnail_display_options);
$description_array[] = (string) $this->renderer->renderPlain(
$description_array[] = (string) $this->renderer->renderInIsolation(
$thumbnail
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function setUp(): void {
$this->installSchema('node', ['node_access']);
$this->installSchema('file', ['file_usage']);

module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function setUp(): void {
'oe_content_person',
]);

module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class PublicationFieldsRequiredValidator extends ConstraintValidator {
* {@inheritdoc}
*/
public function validate($node, Constraint $constraint) {
/** @var \Drupal\node\NodeInterface $node */
if (!isset($node) || $node->getType() !== 'oe_publication') {
return;
}

/** @var \Drupal\node\NodeInterface $node */
$is_collection = (bool) $node->get('oe_publication_collection')->value;

if ($is_collection && $node->get('oe_publication_publications')->isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ protected function setUp(): void {
$this->installEntitySchema($entity);
}

module_load_include('install', 'oe_content_documents_field');
$this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install');
oe_content_documents_field_install(FALSE);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);

$this->installConfig([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function setUp(): void {
'oe_content_sub_entity_author',
'oe_content_sub_entity_author_test',
]);
module_load_include('install', 'oe_content');
$this->container->get('module_handler')->loadInclude('oe_content', 'install');
oe_content_install(FALSE);
}

Expand Down
Loading