icingaweb2 icon indicating copy to clipboard operation
icingaweb2 copied to clipboard

Support PHP 8.2 (one nice day)

Open Al2Klimov opened this issue 2 years ago • 4 comments

Describe the bug

While visiting http://10.27.0.188/icingaweb2/ I get:

  • Deprecated: Creation of dynamic property Icinga\Application\Modules\Module::$configdir is deprecated in /usr/share/icingaweb2/library/Icinga/Application/Modules/Module.php on line 264
  • Fatal error: Uncaught Error: Class "Locale" not found in /usr/share/icinga-php/ipl/vendor/ipl/i18n/src/Locale.php:122 Stack trace: #0 /usr/share/icinga-php/ipl/vendor/ipl/i18n/src/Locale.php(87): ipl\I18n\Locale->parseLocale() #1 /usr/share/icingaweb2/library/Icinga/Application/Web.php(500): ipl\I18n\Locale->getPreferred() #2 /usr/share/icingaweb2/library/Icinga/Application/ApplicationBootstrap.php(719): Icinga\Application\Web->detectLocale() #3 /usr/share/icingaweb2/library/Icinga/Application/Web.php(103): Icinga\Application\ApplicationBootstrap->setupInternationalization() #4 /usr/share/icingaweb2/library/Icinga/Application/ApplicationBootstrap.php(416): Icinga\Application\Web->bootstrap() #5 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\ApplicationBootstrap::start() #6 /usr/share/icingaweb2/public/index.php(4): require_once('...') #7 {main} thrown in /usr/share/icinga-php/ipl/vendor/ipl/i18n/src/Locale.php on line 122

To Reproduce

  1. Get Debian bullseye
  2. Upgrade to bookworm
  3. Upgrade to sid
  4. Add experimental (<-- this is a Debian release codename) repo
  5. apt -t experimental install libapache2-mod-php8.2
  6. git clone https://github.com/Icinga/icingaweb2.git /usr/share/icingaweb2
  7. ln -vs /usr/share/icingaweb2/packages/files/apache/icingaweb2.conf /etc/apache2/conf-enabled/
  8. systemctl reload apache2.service
  9. git clone https://github.com/Icinga/icinga-php-library.git /usr/share/icinga-php/ipl
  10. git clone https://github.com/Icinga/icinga-php-thirdparty.git /usr/share/icinga-php/vendor
  11. Checkout their latest tags

Expected behavior

It works.

Al2Klimov avatar Sep 20 '22 16:09 Al2Klimov

OK, fixed the second one via apt -t experimental install php8.2-intl.

Al2Klimov avatar Sep 20 '22 16:09 Al2Klimov

Oh yes, much better (enabled rewrite mod):

Deprecated: Creation of dynamic property Icinga\Application\Modules\Module::$configdir is deprecated in /usr/share/icingaweb2/library/Icinga/Application/Modules/Module.php on line 264

Deprecated: Creation of dynamic property Icinga\Web\View::$defaultTitle is deprecated in /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php on line 305

Deprecated: Creation of dynamic property Icinga\Web\View::$compact is deprecated in /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php on line 305

Deprecated: Creation of dynamic property Icinga\Web\View::$tabs is deprecated in /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php on line 305
Welcome to Icinga Web 2. For users of the screen reader Jaws full and expectant compliant accessibility is possible only with use of the Firefox browser. VoiceOver on Mac OS X is tested on Chrome, Safari and Firefox.
It appears that you did not configure Icinga Web 2 yet so it's not possible to log in without any defined authentication method. Please define a authentication method by following the instructions in the [documentation](https://icinga.com/docs/icinga-web-2/latest/doc/05-Authentication/#authentication) or by using our [web-based setup-wizard](http://10.27.0.188/icingaweb2/setup).


Deprecated: Creation of dynamic property Zend_Form_Element_Text::$autocapitalize is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$autocomplete is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$class is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$placeholder is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$aria-required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Text::$required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$autocomplete is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$placeholder is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$class is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$aria-required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Password::$required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Icinga\Web\Form\Element\Checkbox::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Icinga\Web\Form\Element\Checkbox::$disabled is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Hidden::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Hidden::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Icinga\Web\Form\Element\CsrfCounterMeasure::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Icinga\Web\Form\Element\CsrfCounterMeasure::$aria-required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Icinga\Web\Form\Element\CsrfCounterMeasure::$required is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Submit::$class is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Submit::$data-progress-label is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Element_Submit::$id is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Element.php on line 863

Deprecated: Creation of dynamic property Zend_Form_Decorator_Label::$optionalPrefix is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/Label.php on line 219

Deprecated: Creation of dynamic property Zend_Form_Decorator_Label::$optionalSuffix is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/Label.php on line 219

Deprecated: Creation of dynamic property Zend_Form_Decorator_Label::$requiredPrefix is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/Label.php on line 219

Deprecated: Creation of dynamic property Zend_Form_Decorator_Label::$requiredSuffix is deprecated in /usr/share/icingaweb2/library/vendor/Zend/Form/Decorator/Label.php on line 219

Al2Klimov avatar Sep 20 '22 16:09 Al2Klimov

We should at least cherry-pick 157ca1939. 1e821ec13 + cda1ae2c7 are indeed monkey-patching Zend 1 and my previous comment is a reason to drop it. Or at least not to use it in our framework + mods code. I mean, if someone is still on, say, Debian 10 (PHP 7.3) and runs IW2 mods w/ "good old" Zend forms, why not to keep that setup working at least for a few IW2 majors?

Al2Klimov avatar Sep 21 '22 12:09 Al2Klimov

Ok, Zend relies on dynamic properties more than I think. E.g. in Zend_Form_Element#getId() it expects the dynamic property $this->id.

Al2Klimov avatar Sep 22 '22 08:09 Al2Klimov

According to PHP RFC: Deprecate dynamic properties PHP 9.0 will throw a fatal error.

Would generous use of #[AllowDynamicProperties] be a viable short term solution?

The PHP maintainers would like to ship Debian bookworm with php8.2, we'll need to fix the icinga packages before the freeze on February 12th 2023 to keep them in the next stable release. This doesn't leave us which much time to get this issue fixed "one nice day".

sebastic avatar Dec 05 '22 08:12 sebastic

Our PM prefers a Zend 1 fork which can PHP 8.2. But it's TBD which one...

Al2Klimov avatar Dec 05 '22 09:12 Al2Klimov

lessphp needs some changes for php8.2 too.

The importDisabled option was removed from lessc.inc.php in icingaweb2 2.9.0, setting it in Icinga/Web/LessCompiler.php does nothing.

I made it work with:

--- icingaweb2/library/vendor/lessphp/lib/Less/Tree/Color.php   2022-12-05 09:38:44.727695421 +0100
+++ /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Color.php        2022-12-05 10:55:37.050370167 +0100
@@ -11,6 +11,7 @@
        public $alpha;
        public $isTransparentKeyword;
        public $type = 'Color';
+       public $name = 'n/a';
 
        public function __construct( $rgb, $a = 1, $isTransparentKeyword = null ) {
                if ( $isTransparentKeyword ) {
diff -ruN icingaweb2/library/vendor/lessphp/lib/Less/Tree/Dimension.php /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Dimension.php
--- icingaweb2/library/vendor/lessphp/lib/Less/Tree/Dimension.php       2022-12-05 09:38:44.731695381 +0100
+++ /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Dimension.php    2022-12-05 10:36:51.322573492 +0100
@@ -11,6 +11,7 @@
        public $value;
        public $unit;
        public $type = 'Dimension';
+       public $parensInOp;
 
        public function __construct( $value, $unit = null ) {
                $this->value = floatval( $value );
diff -ruN icingaweb2/library/vendor/lessphp/lib/Less/Tree/Operation.php /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Operation.php
--- icingaweb2/library/vendor/lessphp/lib/Less/Tree/Operation.php       2022-12-05 09:38:44.731695381 +0100
+++ /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Operation.php    2022-12-05 10:37:52.665853687 +0100
@@ -12,6 +12,7 @@
        public $operands;
        public $isSpaced;
        public $type = 'Operation';
+       public $parensInOp;
 
        /**
         * @param string $op
diff -ruN icingaweb2/library/vendor/lessphp/lib/Less/Tree/Variable.php /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Variable.php
--- icingaweb2/library/vendor/lessphp/lib/Less/Tree/Variable.php        2022-12-05 09:38:44.735695341 +0100
+++ /usr/share/icingaweb2/library/vendor/lessphp/lib/Less/Tree/Variable.php     2022-12-05 10:37:34.578065823 +0100
@@ -13,6 +13,7 @@
        public $currentFileInfo;
        public $evaluating = false;
        public $type = 'Variable';
+       public $parensInOp;
 
        /**
         * @param string $name
--- Icinga/Less/ColorProp.php   2022-12-05 09:41:04.106295070 +0100
+++ /usr/share/php/Icinga/Less/ColorProp.php    2022-12-05 10:44:08.829813222 +0100
@@ -21,7 +21,7 @@
     protected $index;
 
     /** @var string Color variable name */
-    protected $name;
+    public $name;
 
     public function __construct()
     {
diff -ruN Icinga/Util/LessParser.php /usr/share/php/Icinga/Util/LessParser.php
--- Icinga/Util/LessParser.php  2022-12-05 09:41:04.130294827 +0100
+++ /usr/share/php/Icinga/Util/LessParser.php   2022-12-05 10:45:25.949009831 +0100
@@ -10,6 +10,8 @@
 
 class LessParser extends lessc
 {
+    public $importDisabled;
+
     public function __construct()
     {
         $this->setOption('plugins', [new Visitor()]);

HTMLPurifier changes:

--- icingaweb2/library/vendor/HTMLPurifier/AttrTransform/NameSync.php   2022-12-05 09:38:44.171700964 +0100
+++ /usr/share/icingaweb2/library/vendor/HTMLPurifier/AttrTransform/NameSync.php        2022-12-05 11:06:01.043360406 +0100
@@ -8,6 +8,8 @@
 class HTMLPurifier_AttrTransform_NameSync extends HTMLPurifier_AttrTransform
 {
 
+    public $idDef;
+
     public function __construct()
     {
         $this->idDef = new HTMLPurifier_AttrDef_HTML_ID();
diff -ruN icingaweb2/library/vendor/HTMLPurifier/Lexer.php /usr/share/icingaweb2/library/vendor/HTMLPurifier/Lexer.php
--- icingaweb2/library/vendor/HTMLPurifier/Lexer.php    2022-12-05 09:38:44.055702121 +0100
+++ /usr/share/icingaweb2/library/vendor/HTMLPurifier/Lexer.php 2022-12-05 11:05:21.755804666 +0100
@@ -48,6 +48,8 @@
      */
     public $tracksLineNumbers = false;
 
+    public $_entity_parser;
+
     // -- STATIC ----------------------------------------------------------
 
     /**

Further icingaweb2 changes in addition to those from #4920:

--- Icinga/Web/Navigation/ConfigMenu.php        2022-12-05 09:41:04.178294342 +0100
+++ /usr/share/php/Icinga/Web/Navigation/ConfigMenu.php 2022-12-05 10:22:45.480701123 +0100
@@ -33,6 +33,8 @@
 
     protected $state;
 
+    protected $title;
+
     public function __construct()
     {
         $this->children = [

icinga-php-library changes for options present in /etc/icingaweb2/resources.ini:

diff -ruN icinga-php/ipl/vendor/ipl/sql/src/Config.php /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Config.php
--- icinga-php/ipl/vendor/ipl/sql/src/Config.php        2022-12-05 10:59:49.479548990 +0100
+++ /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Config.php     2022-12-05 10:21:06.309935810 +0100
@@ -33,6 +33,9 @@
         }
     }
 
+    /** @var string Database type */
+    public $type;
+
     /** @var string Type of the DBMS */
     public $db;
 
@@ -51,6 +54,9 @@
     /** @var string Password to use for authentication */
     public $password;
 
+    /** @var bool Use SSL for connection */
+    public $use_ssl;
+
     /**
      * Character set for the connection
      *

Properties for all the (optional) resource options should probably be added.

E.g.:

--- a/vendor/ipl/sql/src/Config.php
+++ b/vendor/ipl/sql/src/Config.php
@@ -33,6 +33,9 @@ class Config
         }
     }

+    /** @var string Database type */
+    public $type;
+
     /** @var string Type of the DBMS */
     public $db;

@@ -51,6 +54,27 @@ class Config
     /** @var string Password to use for authentication */
     public $password;

+    /** @var bool Use SSL for connection */
+    public $use_ssl;
+
+    /** @var bool Don't verify SSL cerificate */
+    public $ssl_do_not_verify_server_cert;
+
+    /** @var string Path to SSL certificate */
+    public $ssl_cert;
+
+    /** @var string Path to SSL key */
+    public $ssl_key;
+
+    /** @var string Path to SSL CA file */
+    public $ssl_ca;
+
+    /** @var string Path to SSL CA directory */
+    public $ssl_capath;
+
+    /** @var string SSL ciphers */
+    public $ssl_cipher;
+
     /**
      * Character set for the connection
      *

icinga-php-thirdparty changes for icingadb-web:

diff -ruN icinga-php/vendor/vendor/guzzlehttp/psr7/src/CachingStream.php /usr/share/icinga-php/vendor/vendor/guzzlehttp/psr7/src/CachingStream.php
--- icinga-php/vendor/vendor/guzzlehttp/psr7/src/CachingStream.php      2022-12-05 10:58:51.728196678 +0100
+++ /usr/share/icinga-php/vendor/vendor/guzzlehttp/psr7/src/CachingStream.php   2022-12-05 11:10:42.980166081 +0100
@@ -20,6 +20,8 @@
     /** @var int Number of bytes to skip reading due to a write on the buffer */
     private $skipReadBytes = 0;

+    private $stream;
+
     /**
      * We will treat the buffer object as the body of the stream
      *

icingadb-web changes:

--- a/library/Icingadb/Widget/Detail/DowntimeCard.php
+++ b/library/Icingadb/Widget/Detail/DowntimeCard.php
@@ -15,6 +15,9 @@ class DowntimeCard extends BaseHtmlEleme
 {
     protected $downtime;
 
+    protected $start;
+    protected $end;
+
     protected $duration;
 
     protected $defaultAttributes = ['class' => 'progress-bar downtime-progress'];

sebastic avatar Dec 05 '22 10:12 sebastic

🚀Cool!🚀 Please could you, as the author of those changes, PR them to upstream?

Al2Klimov avatar Dec 05 '22 11:12 Al2Klimov

If they don't have a CLA like Icinga. As a volunteer I don't get paid enough to deal with the legal shenanigans of CLAs. I already spend far too much time on license & copyright review of new upstream releases.

These changes seem trivial enough to not be copyrightable, but if they are then I disclaim any rights, anyone is free to use those changes as they see fit.


dompdf 2.0.0 has changes for PHP 8.2:

  • https://github.com/dompdf/dompdf/commit/fb09529dddb503f21ea8d4121b71dedc6f93c8ba

guzzlehttp/psr7 is already fixed since 2.4.0:

  • https://github.com/guzzle/psr7/commit/b4719a1466c0a07be786ed9950f34e8ccb39277a

HTMLPurifier is already fixed since 4.15.0:

  • https://github.com/ezyang/htmlpurifier/commit/1db36fb09d4ab1bce79722014e70e7a96ad76165
  • https://github.com/ezyang/htmlpurifier/commit/1b80051115bba8f3c046c1bd00af9077071d3faf

lessphp:

  • https://github.com/wikimedia/less.php/pull/86

sebastic avatar Dec 05 '22 11:12 sebastic

@TAINCER Can you please get an overview of what has already been done and what still needs to be done? You are also welcome to review the linked PR.

lippserd avatar Jan 13 '23 08:01 lippserd

icinga-php-library 0.11.0 (re)introduced deprecation warnings:

Deprecated
: Creation of dynamic property GuzzleHttp\Psr7\CachingStream::$stream is deprecated in
/usr/share/icinga-php/ipl/vendor/guzzlehttp/psr7/src/CachingStream.php
on line
34

The guzzlehttp/psr7 file in question is also provided by icinga-php-thirdparty.

sebastic avatar Mar 23 '23 06:03 sebastic

Grabbing the latest ipl/sql repo and dumping it over the top worked for me on debian bookworm. I'm left with one deprecated warning: Deprecated: Creation of dynamic property GuzzleHttp\Psr7\CachingStream::$stream is deprecated in /usr/share/icinga-php/vendor/vendor/guzzlehttp/psr7/src/CachingStream.php on line 34

I tried to grab the latest guzzlehttp/psr7 version from here: https://github.com/guzzle/psr7 but that makes things much worse (the UI doesn't load at all, with include errors), so I'm not sure which one to get.

Debian bookworm is out and about, and we have started using it in production for new images. Got any quick tip on how to remove the deprecated warning related to guzzle? I would love to see the packages.icinga.com repo updated with debian 12 at some point, for those early adopters :)

davekempe avatar Aug 13 '23 22:08 davekempe

Ah I see a PR is awaiting merge https://github.com/Icinga/icingaweb2/pull/4920 so perhaps I should just wait for that.

davekempe avatar Aug 13 '23 23:08 davekempe

It works, now.

nilmerg avatar Aug 31 '23 13:08 nilmerg