Skip to content

Commit

Permalink
EWPP-4991: Ensure PHP8.3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagyad committed Jan 21, 2025
1 parent a3dc064 commit 792e8d5
Show file tree
Hide file tree
Showing 36 changed files with 74 additions and 87 deletions.
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_theme
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
- MYSQL_DATABASE=drupal
Expand Down Expand Up @@ -130,22 +130,22 @@ pipeline:

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

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

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

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

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

- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: behat }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: phpunit, BATCH: batch1 }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: phpunit, BATCH: batch2 }
- { PHP_VERSION: 8.3, CORE_VERSION: 10.4.0, TYPE: phpunit, BATCH: batch3 }
24 changes: 15 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"mikey179/vfsstream": "^1.6.10",
"nikic/php-parser": "^4.18",
"openeuropa/behat-transformation-context": "^0.2",
"openeuropa/code-review": "^2.0.0-alpha6",
"openeuropa/code-review-drupal": "^1.0.0-alpha",
"openeuropa/oe_contact_forms": "^1.14",
"openeuropa/oe_content": "^4.0.0",
"openeuropa/oe_corporate_blocks": "4.x-dev",
Expand All @@ -57,7 +57,7 @@
"openeuropa/oe_search": "^2.0@beta",
"openeuropa/oe_webtools": "^1.23",
"openeuropa/rdf_skos": "^1.0.0",
"openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta6",
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"phpspec/prophecy-phpunit": "^2",
"symfony/phpunit-bridge": "^6.0"
},
Expand All @@ -83,16 +83,20 @@
"Drupal\\Tests\\oe_media\\": "./build/modules/contrib/oe_media/tests/src/"
}
},
"repositories": {
"drupal": {
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
"media_avportal": {
{
"type": "git",
"url": "https://github.com/openeuropa/media_avportal"
"url": "https://github.com/openeuropa/DrupalDriver.git"
},
{
"type": "git",
"url": "https://github.com/openeuropa/code-review-drupal.git"
}
},
],
"extra": {
"composer-exit-on-patch-failure": true,
"enable-patching": true,
Expand Down Expand Up @@ -129,11 +133,13 @@
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/core-composer-scaffold": true,
"php-http/discovery": false,
"phpro/grumphp": true,
"php-http/discovery": false
"phpro/grumphp-shim": true,
"phpstan/extension-installer": true
}
}
}
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.1
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
33 changes: 6 additions & 27 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
imports:
- { resource: vendor/openeuropa/code-review/dist/drupal-conventions.yml }
parameters:
tasks.phpcs.ignore_patterns:
- vendor/
- node_modules/
- build/
tasks.phpcs.triggered_by:
- php
- module
- inc
- theme
- install

extra_tasks:
- { resource: ./vendor/openeuropa/code-review-drupal/dist/oe-component-conventions.yml }
grumphp:
tasks:
phpparser:
ignore_patterns:
- vendor/
- node_modules/
- build/
visitors:
declare_strict_types: ~
triggered_by:
- php
- module
- inc
- theme
- install
grumphp:
extensions:
- OpenEuropa\CodeReview\ExtraTasksExtension
git_hook_variables:
EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web'

parameters:
tasks.phpstan.configuration: phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ dependencies:
- oe_content:oe_content_call_tenders
- oe_theme:oe_theme_helper
- oe_time_caching:oe_time_caching


Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 1140
height: 380
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 1140
height: 285
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 1140
height: 228
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 996
height: 332
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 996
height: 249
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 996
height: 199
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 768
height: 256
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 768
height: 192
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 480
height: 160
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 480
height: 120
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ effects:
width: 480
height: 96
anchor: center-center

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function defaultSettings() {
* {@inheritdoc}
*/
public function settingsSummary() {
$settings = $this->getSettings();
$summary = parent::settingsSummary();

if (!empty($settings['title'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getSource(MediaInterface $media): ?string {
->viewField($media->get($source_field), 'oe_theme_main_content');

// Bubble the cacheability information in the current render context.
$markup = $this->renderer->renderPlain($build);
$markup = $this->renderer->renderInIsolation($build);

// If the source is rendered as iframe tag, use the src attribute.
if (isset($build[0]['#type']) && $build[0]['#type'] === 'html_tag' && $build[0]['#tag'] === 'iframe') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ name: 'PageHeaderMetadata test'
type: module
description: 'PageHeaderMetadata test module.'
package: Testing
version: VERSION
core_version_requirement: ^10
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function setUp(): void {
]);

// Call the install hook of the Media module.
module_load_include('install', 'media');
$this->container->get('module_handler')->loadInclude('media', 'install');
media_install();

// Create a content type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function setUp(): void {
]);

// Call the install hook of the Media module.
module_load_include('install', 'media');
$this->container->get('module_handler')->loadInclude('media', 'install');
media_install();

// Add a copyright field to some of the media bundles used in the test. Use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function setUp(): void {
]);

// Call the install hook of the Media module.
module_load_include('install', 'media');
$this->container->get('module_handler')->loadInclude('media', 'install');
media_install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ hidden:
created: true
field_oe_banner_type: true
status: true

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ label: 'Simple banner'
description: ''
targetEntityType: paragraph
cache: true

Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ hidden:
created: true
field_oe_banner_type: true
status: true

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ label: 'Simple banner'
description: ''
targetEntityType: paragraph
cache: true

1 change: 0 additions & 1 deletion modules/oe_theme_test/oe_theme_test.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ type: module
description: 'OpenEuropa theme test module.'
package: OpenEuropa
hidden: true
version: VERSION
core_version_requirement: ^10

config_devel:
Expand Down
12 changes: 10 additions & 2 deletions oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,11 @@ function oe_theme_preprocess_paragraph__oe_banner(array &$variables): void {

// Load needed images styles based on banner size.
$image_style_storage = \Drupal::entityTypeManager()->getStorage('image_style');
$full_width = NULL;
$extra_large = NULL;
$large = NULL;
$medium = NULL;
$small = NULL;
if ($variables['size'] === 's') {
$full_width = $image_style_storage->load('oe_theme_full_width_banner_5_1');
$extra_large = $image_style_storage->load('oe_theme_extra_large_5_1_banner');
Expand Down Expand Up @@ -2124,7 +2129,6 @@ function oe_theme_preprocess_paragraph__oe_illustration_list_images(array &$vari
$language_id = $paragraph->language()->getId();
$sub_paragraph = $entity_repository->getTranslationFromContext($sub_paragraph, $language_id);
// Get the image from attached media.
$image = [];
$media = _oe_theme_prepare_media($sub_paragraph->get('field_oe_media')->entity, $variables['user'], $cacheability, $language_id);
if ($media) {
$thumbnail = '';
Expand Down Expand Up @@ -2232,6 +2236,11 @@ function oe_theme_preprocess_paragraph__oe_carousel(array &$variables): void {
$variables['size'] = substr($paragraph->get('field_oe_carousel_size')->value, 0, 1);
}
// Load needed images styles based on carousel size.
$full_width = NULL;
$extra_large = NULL;
$large = NULL;
$medium = NULL;
$small = NULL;
$image_style_storage = \Drupal::entityTypeManager()->getStorage('image_style');
if ($variables['size'] === 's') {
$full_width = $image_style_storage->load('oe_theme_full_width_banner_5_1');
Expand Down Expand Up @@ -2261,7 +2270,6 @@ function oe_theme_preprocess_paragraph__oe_carousel(array &$variables): void {
$sub_paragraph = \Drupal::service('entity.repository')
->getTranslationFromContext($sub_paragraph, $paragraph->language()->getId());
// Add CTA, Title and description if available.
$link = '';
$link_text = '';
if (!$sub_paragraph->get('field_oe_link')->isEmpty()) {
/** @var \Drupal\link\Plugin\Field\FieldType\LinkItem $link_item */
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- ./vendor/openeuropa/code-review-drupal/dist/phpstan.drupal.neon
2 changes: 1 addition & 1 deletion templates/patterns/link/link.ui_patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ link:
type: "array"
label: "Contextual links"
description: "Render array of contextual links"
preview: ~
preview: ~
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ navigation_list:
preview:
src: "https://loremflickr.com/1000/500/arch"
alt: "Alternative text for image"

1 change: 0 additions & 1 deletion templates/patterns/tabs/tabs.ui_patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ tabs:
label: 'Extra classes string'
description: 'Extra classes string'
preview: ''

2 changes: 1 addition & 1 deletion tests/src/Functional/CorporateFooterRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function testCorporateFooterRendering(): void {
$this->assertEquals('Discover more on <a href="https://europa.eu/" class="ecl-link ecl-link--standalone">europa.eu</a>', trim($actual->getHtml()));

// Assert presence of ecl logo in the standardised footer.
$this->assertEclLogoPresence($section, 'European Union');
$this->assertEclLogoPresence($section);

$column = $assert->elementExists('css', 'footer.ecl-site-footer div.ecl-site-footer__row:nth-child(2) div.ecl-site-footer__column:nth-child(2)');
$subsection = $assert->elementExists('css', '.ecl-site-footer__section:nth-child(1)', $column);
Expand Down
14 changes: 14 additions & 0 deletions tests/src/Kernel/ContactRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ class ContactRenderTest extends ContentRenderTestBase {
'oe_theme_content_entity_contact',
];

/**
* The contact entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $contactStorage;

/**
* The contact view builder.
*
* @var \Drupal\Core\Entity\EntityViewBuilderInterface
*/
protected $contactViewBuilder;

/**
* {@inheritdoc}
*/
Expand Down
Loading

0 comments on commit 792e8d5

Please sign in to comment.