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

Smarty is not compatible with PHP 8.1 #671

Closed
ildar-aim opened this issue Jul 26, 2021 · 10 comments
Closed

Smarty is not compatible with PHP 8.1 #671

ildar-aim opened this issue Jul 26, 2021 · 10 comments

Comments

@ildar-aim
Copy link

ildar-aim commented Jul 26, 2021

https://github.com/php/php-src/blob/php-8.1.0/UPGRADING

https://www.php.net/index.php#id2021-07-22-1

For example, this patch causes a fatal error

aim-server[~/www/smarty/demo]$ gitdiff .
diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl
index 1fbb6d37..1e125e15 100644
--- a/demo/templates/index.tpl
+++ b/demo/templates/index.tpl
@@ -1,6 +1,6 @@
 {config_load file="test.conf" section="setup"}
 {include file="header.tpl" title=foo}
-
+{php}{/php}
 <PRE>
 
 {* bold and title are read from the config file *}
Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in public_html/smarty/libs/sysplugins/smartycompilerexception.php on line 8

The expected error is

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:public_html/smarty/demo/templates/index.tpl" on line 3 "{php}{/php}" {php}{/php} tags not allowed. Use SmartyBC to enable them <-- thrown in public_html/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 3
@pilif
Copy link

pilif commented Aug 23, 2021

what's really nasty is that fixing the class to work with 8.1 makes it break for < 8.1.

the only fix I see is to either conditionally define the class depending on PHP version or alternatively renaming the property and using the changed name instead.

Which one would you prefer? I can do a PR for both.

@ildar-aim
Copy link
Author

I have created a copy of Smarty.class.php -
Smarty.PHP81.class.php

and the code is

if (PHP_VERSION_ID >= 80100) { // php 8.1.0 
    require_once(dirname(__FILE__) . '/Smarty.PHP81.class.php');
} else {
    require_once(dirname(__FILE__) . '/Smarty.class.php');
}

@Bigbear7
Copy link

Is this the same as the issue that was raised on PHP internals list?
https://externals.io/message/115683

@ildar-aim
Copy link
Author

I guess so

@Bigbear7
Copy link

It has now been discussed a little on the PHP internals list:

@wisskid
Copy link
Contributor

wisskid commented Oct 13, 2021

See #678

@genyslt
Copy link

genyslt commented Jan 5, 2022

Any news?

@glensc
Copy link
Contributor

glensc commented Jan 10, 2022

if the problem being $line being re-declared as public from inherited Exception class, can it be declared as private if used only in that class?

@wisskid
Copy link
Contributor

wisskid commented Jan 10, 2022

@glensc yes, see #678

@Bigbear7
Copy link

Just started with running our test site on PHP 8.1 and the RFC https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg about passing null to internal functions is generating deprecation warnings, e.g. in plugin modifier.truncate.php for mb_substr function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants