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

Support PHP 8.2 (one nice day) #4918

Closed
Al2Klimov opened this issue Sep 20, 2022 · 14 comments · Fixed by #5040
Closed

Support PHP 8.2 (one nice day) #4918

Al2Klimov opened this issue Sep 20, 2022 · 14 comments · Fixed by #5040
Assignees
Labels
enhancement New feature or improvement
Milestone

Comments

@Al2Klimov
Copy link
Member

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
Copy link
Member Author

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

@Al2Klimov
Copy link
Member Author

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 Al2Klimov self-assigned this Sep 21, 2022
@Al2Klimov Al2Klimov linked a pull request Sep 21, 2022 that will close this issue
@Al2Klimov
Copy link
Member Author

We should at least cherry-pick 157ca19. 1e821ec + cda1ae2 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
Copy link
Member Author

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 Al2Klimov removed their assignment Sep 22, 2022
@sebastic
Copy link
Contributor

sebastic commented Dec 5, 2022

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".

@Al2Klimov
Copy link
Member Author

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

@sebastic
Copy link
Contributor

sebastic commented Dec 5, 2022

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'];

@Al2Klimov
Copy link
Member Author

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

@sebastic
Copy link
Contributor

sebastic commented Dec 5, 2022

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:

guzzlehttp/psr7 is already fixed since 2.4.0:

HTMLPurifier is already fixed since 4.15.0:

lessphp:

@lippserd
Copy link
Member

@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.

@sebastic
Copy link
Contributor

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.

@davekempe
Copy link

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
Copy link

Ah I see a PR is awaiting merge #4920 so perhaps I should just wait for that.

@nilmerg nilmerg linked a pull request Aug 31, 2023 that will close this issue
@nilmerg nilmerg added the enhancement New feature or improvement label Aug 31, 2023
@nilmerg
Copy link
Member

nilmerg commented Aug 31, 2023

It works, now.

@nilmerg nilmerg closed this as completed Aug 31, 2023
@nilmerg nilmerg added this to the 2.12.0 milestone Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants