PHP 8.2 compatibility, fix deprecations

Created on 20 December 2023, 12 months ago
Updated 12 September 2024, 3 months ago

Problem/Motivation

wingsuit_companion uses a few deprecated functions has a few other issues.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany webflo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @webflo
  • Status changed to Needs review 12 months ago
  • 🇩🇪Germany webflo

    Self-review with a few explanations.

    1. +++ b/modules/wingsuit_ui_patterns/src/Plugin/Deriver/LibraryDeriver.php
      @@ -120,7 +126,7 @@ class LibraryDeriver extends AbstractYamlPatternsDeriver {
      -    $this->config = $config_factory->getEditable('wingsuit_companion.config');
      +    $this->configFactory = $config_factory;
      

      $this->config Property was dynamically created. This is deprecated in PHP 8.2. The config factory should be injected instead.

      See https://mglaman.dev/blog/dependency-injection-anti-patterns-drupal for more information.

    2. +++ b/modules/wingsuit_ui_patterns/src/TwigExtension/WingsuitExtension.php
      @@ -5,14 +5,13 @@ namespace Drupal\wingsuit_ui_patterns\TwigExtension;
      +class WingsuitExtension extends AbstractExtension {
      

      The TwigExtension class should not be extended, since its the default extension on Drupal core.

  • 🇬🇧United Kingdom Finn Lewis

    Thanks for the patch @webflo.

    I was also getting the following warnings:

    Deprecated function: Creation of dynamic property Drupal\wingsuit_companion\StreamWrapper\WingsuitStreamWrapper::$config is deprecated in Drupal\wingsuit_companion\StreamWrapper\WingsuitStreamWrapper->__construct() (line 46 of modules/contrib/wingsuit_companion/src/StreamWrapper/WingsuitStreamWrapper.php).
    Deprecated function: Creation of dynamic property Drupal\wingsuit_companion\StreamWrapper\WingsuitStreamWrapper::$request is deprecated in Drupal\wingsuit_companion\StreamWrapper\WingsuitStreamWrapper->getRequest() (line 110 of modules/contrib/wingsuit_companion/src/StreamWrapper/WingsuitStreamWrapper.php).

    I've extended to patch to suppress these, but could do with your review to check I've done it the right way.

  • 🇩🇪Germany Patrick R.

    The $basePluginId property should be removed form modules/wingsuit_ui_patterns/src/Plugin/Deriver/LibraryDeriver.php - it's already declared in Drupal\ui_patterns\Plugin\Deriver\AbstractPatternsDeriver which is extended by this class but the base definition was apparently updated in ui_patterns 8.x-1.8 release so this will now cause a fatal error.

    
    /**
     * The base plugin ID.
     *
     * @var string
     */
    protected $basePluginId;
    
    
  • 🇬🇧United Kingdom 8bitplateau

    Slightly different version with some more fixes for PHPStorm and installation.

    I was getting the following error:

    Fatal error: Type of Drupal\wingsuit_ui_patterns\Plugin\Deriver\LibraryDeriver::$basePluginId must be string (as in class Drupal\ui_patterns\Plugin\Deriver\AbstractPatternsDeriver) in /var/www/html/web/modules/contrib/wingsuit_companion/modules/wingsuit_ui_patterns/src/Plugin/Deriver/LibraryDeriver.php on line 22

    so added some types

  • Status changed to Fixed 9 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇬🇧United Kingdom Finn Lewis

    Thanks for this @Christian.wiedemann

    Any chance of a new tagged release to support PHP 8.2?

  • I ran into this as well. A tagged release would be nice.

  • 🇬🇧United Kingdom welly

    Feel free to ignore this but added a backport of the patch for the 8.x-2.1release.

Production build 0.71.5 2024