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

[3.10][PHP8.1, Xampp] PHP Error on white page instead of redirection to Joomla's error page #37035

Closed
ReLater opened this issue Feb 14, 2022 · 11 comments

Comments

@ReLater
Copy link
Contributor

ReLater commented Feb 14, 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

@zero-24
Copy link
Member

zero-24 commented Feb 14, 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 = '';

@ReLater
Copy link
Contributor Author

ReLater commented Feb 14, 2022

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

@ManuelHu
Copy link
Contributor

ManuelHu commented Feb 15, 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:

@ReLater
Copy link
Contributor Author

ReLater commented Feb 15, 2022

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

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

@ManuelHu
Copy link
Contributor

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

@zero-24
Copy link
Member

zero-24 commented Feb 15, 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?

@ManuelHu
Copy link
Contributor

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

@zero-24
Copy link
Member

zero-24 commented Feb 15, 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?

@ManuelHu
Copy link
Contributor

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.

@zero-24
Copy link
Member

zero-24 commented Feb 15, 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.

@zero-24
Copy link
Member

zero-24 commented Feb 16, 2022

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

@zero-24 zero-24 closed this as completed Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants