No Code Attached Yet
avatar ReLater
ReLater
14 Feb 2022

Steps to reproduce the issue

  • XAMPP 8.1, Win 10
  • Install blank J3.10.5 without any additional clicks (language or so).
  • Go to frontend
  • Enter a wrong URL in address bar. E.g. http://localhost/j3-php81/aaaaaaaaa
  • Error: Fatal error: Type of JException::$file must be string (as in class Exception) in Z:\xampp810\htdocs\j3-php81\libraries\legacy\exception\exception.php on line 18
  • Activated sef links and .htaccess. Same behavior.
  • Setting Error Reporting to maximum crashed backend after next trial to save the configuration.
  • Updated to nightly "3.10.6-rc2-dev.". Can save configuration now but rest: Same behavior.
    • Debug or higher Error reporting doesn't show more. No backtrace.
  • Just some more deprecated on white frontend page with wrong URL.
Deprecated: Joomla\Input\Input implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in Z:\xampp810\htdocs\j3-php81\libraries\vendor\joomla\input\src\Input.php on line 41

Deprecated: Return type of Joomla\Input\Input::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Z:\xampp810\htdocs\j3-php81\libraries\vendor\joomla\input\src\Input.php on line 170

Deprecated: Joomla\CMS\Input\Input implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in Z:\xampp810\htdocs\j3-php81\libraries\src\Input\Input.php on line 31

Deprecated: Joomla\CMS\Input\Cookie implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in Z:\xampp810\htdocs\j3-php81\libraries\src\Input\Cookie.php on line 21

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Z:\xampp810\htdocs\j3-php81\libraries\src\Uri\Uri.php on line 143

Fatal error: Type of JException::$file must be string (as in class Exception) in Z:\xampp810\htdocs\j3-php81\libraries\legacy\exception\exception.php on line 18

I have tested that with "more complete" J3 sites. Same behavior.

Maybe related: #37015

avatar ReLater ReLater - open - 14 Feb 2022
avatar joomla-cms-bot joomla-cms-bot - change - 14 Feb 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Feb 2022
avatar ReLater ReLater - change - 14 Feb 2022
The description was changed
avatar ReLater ReLater - edited - 14 Feb 2022
avatar zero-24
zero-24 - comment - 14 Feb 2022

Fatal error: Type of JException::$file must be string (as in class Exception) in Z:\xampp810\htdocs\j3-php81\libraries\legacy\exception\exception.php on line 18

Can you try what happens when you replace this line: https://github.com/joomla/joomla-cms/blob/3.10-dev/libraries/legacy/exception/exception.php#L64
with
protected $file = '';

avatar ReLater
ReLater - comment - 14 Feb 2022

No change with protected $file = ''; with 3.10.6-rc2-dev (current nightly).

avatar ReLater ReLater - change - 14 Feb 2022
The description was changed
avatar ReLater ReLater - edited - 14 Feb 2022
avatar ManuelHu
ManuelHu - comment - 15 Feb 2022

I found that bug a while ago (but apparently forgot to open an issue about it). This has nothing to do with xampp nor windows, as this happened on PHP 8.1 on a linux server as well.

The problem is, that of PHP 8.1 the Exception class has now type hints for all it's properties, which now cannot be overridden without specifying the exactly same type hint.
So protected string $file = ''; should do the trick - at least for this one line. All other properties would have to be changed in a similar way.

But there is a catch - this changed line is now a compile error on all PHP versions lower that 8.1.

See also:

avatar ReLater
ReLater - comment - 15 Feb 2022

So protected string $file = ''; should do the trick

As said above. It didn't in libraries/legacy/exception/exception.php#L64.

avatar ManuelHu
ManuelHu - comment - 15 Feb 2022

There is an additional string before the $file in my code snippet, compared to the first suggestion :-)

avatar zero-24
zero-24 - comment - 15 Feb 2022

So protected string $file = ''; should do the trick - at least for this one line. All other properties would have to be changed in a similar way.

@ManuelHu Could you do a full PR against 3.10-dev so we can include the changes with our next release?

avatar ManuelHu
ManuelHu - comment - 15 Feb 2022

@zero-24 I'm not sure this is a good way - adding the type hints would break all sites on php 7.x and 8.0... (See both example links in my first answer).
The only way forward in my eyes would be to remove the re-declared properties from joomla - I don't really see a point any more for including them as php already defines them as protected.

avatar zero-24
zero-24 - comment - 15 Feb 2022

I'm not sure this is a good way - adding the type hints would break all sites on php 7.x and 8.0... (See both example links in my first answer).

Ah yes thats not a good thing :D

The only way forward in my eyes would be to remove the re-declared properties from joomla - I don't really see a point any more for including them as php already defines them as protected.

Does that work down to 5.3.10 too, as this is the minimum version of 3.10?

avatar ManuelHu
ManuelHu - comment - 15 Feb 2022

5.3.10 also appears to have the properties set-up as protected, too (var_dump( new Exception() ):

Output for 5.3.10 | released 2012-02-02 | took 10 ms, 13 MiB
    object(Excpetion)#1 (7) {
      ["file":protected]=>
      string(9) "/in/rqAnp"
      ["message":protected]=>
      string(0) ""
      ["string":"Exception":private]=>
      string(0) ""
      ["code":protected]=>
      int(0)
      ["line":protected]=>
      int(9)
      ["trace":"Exception":private]=>
      array(0) {
      }
      ["previous":"Exception":private]=>
      NULL
    }

This should work as expected, at least I don't see anything that would break. But I haven't worked with such ancient php versions for a long time...

Removing the properties would also remove the deprecation tags and the joomla doc blocks...

I could prepare a pull request tomorrow.

avatar zero-24
zero-24 - comment - 15 Feb 2022

This should work as expected, at least I don't see anything that would break.

Great!

I could prepare a pull request tomorrow.

Thanks once done I will take the PR and run it against a local 5.3.10 to be sure.

avatar zero-24 zero-24 - change - 16 Feb 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-02-16 22:21:56
Closed_By zero-24
avatar zero-24 zero-24 - close - 16 Feb 2022
avatar zero-24
zero-24 - comment - 16 Feb 2022

PR has been created here: #37074 (comment) thanks @ManuelHu

Add a Comment

Login with GitHub to post a comment