smarty-php
Repos
4

Events

Created at 23 minutes ago
Created at 23 minutes ago
issue comment
Drop support for using PHP functions as modifiers

This is nice change, but i think the error maybe can show caller. It's a problem with large/dynamics layouts

Created at 21 hours ago
issue comment
Construction: switch - case

Hi guys! Do you really need switch/case? Just because there is {if}, {elseif} and {/if} already. Smarty3 documentation for if For Smarty4, the documentation is not enough complete to find {elseif}, but probably exists.

Created at 21 hours ago
Created at 1 day ago
issue comment
Drop support for using PHP functions as modifiers

I struggled a bit to identify which functions would trigger this warning so I wrote a regex to match custom modifiers, excluding built-in modifiers, in case anybody finds it useful

\{(.+(?=\|))\|*(\b(?!capitalize|count|date_format|debug_print_var|escape|explode|mb_wordwrap|number_format|regex_replace|replace|spacify|truncate|cat|count_characters|count_paragraphs|count_sentences|count_words|default|escape|from_charset|indent|lower|nl2br|noprint|round|str_repeat|string_format|strip|strip_tags|strlen|to_charset|unescape|upper|wordwrap|trimwhitespace\b)[A-Za-z0-9_:$'->?]+)\}

https://regexr.com/7413e image

Created at 1 day ago
Created at 2 days ago
Created at 2 days ago
Created at 3 days ago
Created at 5 days ago
Created at 6 days ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
closed issue
Smarty_Internal_ErrorHandler doesn't check error_reporting() to comply with php error configuration

When I set error_reporting in my application to suppress e.g. E_NOTICE (or other) errors, smarty 4.x does not respect that setting when it calls some of my custom smarty plugins.

The documentation of set_error_handler mentions that custom error handlers are called independent of the configured error levels, and contains example code how to respect the configured error levels in a custom error handler.

Applied to smarty, the solution for that problem should be to add at the beginning of

https://github.com/smarty-php/smarty/blob/f8e1ba76f77e17ec7b364b2922d350990ead7168/libs/sysplugins/smarty_internal_errorhandler.php#L67-L78 the following lines of code:

        if (!(error_reporting() & $errno)) {
            return; // suppresses this error
        }

This might also solve some of the other issues related to error handling ( #759 and maybe others )

Created at 1 week ago
issue comment
Smarty_Internal_ErrorHandler doesn't check error_reporting() to comply with php error configuration

No problem! Thank you for uour kind words. 😊

Created at 1 week ago
issue comment
Smarty_Internal_ErrorHandler doesn't check error_reporting() to comply with php error configuration

You're right. When I added this fix half a year ago to my own codebase, it seemed to help to suppress unwanted php warningsI was fighting PHP warnings. Later I added some more fixes for php warnings in my own error handler. Now i tried for three hours to reproduce the difference of (not) checking error_reporting in handleError(), but I couldn't. Your explanation makes sense - and as you don't do any actions in handleError(), it makes sense that checking error_reporting in my own error handler is enough. Thanks for your great work with Smarty, and sorry for all circumstances.

Created at 1 week ago
issue comment
Drop support for using PHP functions as modifiers

libs/debug.tpl still contains "|md5"

Created at 1 week ago
Created at 1 week ago
issue comment
Drop support for using PHP functions as modifiers

I agree with @wisskid that these are better served as separate modifier plug-ins. Perhaps a contrib folder could be added to the repo for third party (non-supported) add-ons?

+1 I hope they will provide a separate repo with all modifiers. Really needed for legacy projects.

Anyway, this update is confusing.

Created at 1 week ago
Created at 1 week ago
issue comment
Allow dereferencing of non-objects accross all supported PHP versions

What about

class Foo {}
$smarty->assign('object', new Foo);
====
{{$object->name}}

? Is that caught too? A non-existing property of a valid object? Or a protected/private property of an object, which is probably a different message:

class Foo {
  protected $name = 'Bar';
}
$smarty->assign('object', new Foo);
====
{{$object->name}}
Created at 1 week ago
issue comment
Allow dereferencing of non-objects accross all supported PHP versions

I have no idea what DereferencingNonObjects is, so I would put all those error suppression in the same config, but sure, this works :+1:

Created at 1 week ago
closed issue
Dereferencing of non-object triggers E_WARNING in php >= 8.0
$smarty->assign('object', null);
====
{{$object->name}}

That would trigger a

Attempt to read property "name" on null

Originally posted by @rudiedirkx in https://github.com/smarty-php/smarty/issues/735#issuecomment-1326258423

Created at 1 week ago

Allow dereferencing of non-objects accross all supported PHP versions (#832)

Fixes #831

Created at 1 week ago
pull request closed
Allow dereferencing of non-objects accross all supported PHP versions

Fixes #831

Created at 1 week ago
pull request closed
Fix error handler allowUndefinedVars

handleError only checks for property value, which is odd. I'm getting error

Attempt to read property "id" on null

Because id is the property being accessed. So it should check for any property name, not just value.

Created at 1 week ago
issue comment
Fix error handler allowUndefinedVars

I propose a slightly different implementation, see https://github.com/smarty-php/smarty/pull/832

Created at 1 week ago
pull request opened
Allow dereferencing of non-objects accross all supported PHP versions

Fixes #831

Created at 1 week ago
create branch
wisskid create branch feature/dereferencing_of_non_objects
Created at 1 week ago