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
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
Labels |
Added:
No Code Attached Yet
|
No change with protected $file = '';
with 3.10.6-rc2-dev (current nightly).
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:
So protected string $file = ''; should do the trick
As said above. It didn't in libraries/legacy/exception/exception.php#L64.
There is an additional string
before the $file
in my code snippet, compared to the first suggestion :-)
@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.
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?
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.
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.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-02-16 22:21:56 |
Closed_By | ⇒ | zero-24 |
PR has been created here: #37074 (comment) thanks @ManuelHu
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 = '';