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

upgrade smarty to v5.4.0 #973

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdaniels5757
Copy link
Contributor

Breaking this out per #969.

@stwalkerster
Copy link
Member

I've not spent too much time testing this properly yet, but I am seeing a few things.

It looks like the fix we did for the implode modifier in #965 hasn't worked as Smarty still has an implode modifier built-in (and throwing deprecation warnings). I've bodged it on team/user.tpl locally, but I'm not sure if this is all cases we need to fix:

-  <li>{'</li><li>'|implode:$infoContent}</li>
+  <li>{$infoContent|join:'</li><li>'}</li>

There's also a lot of deprecation warnings being thrown by TemplateOutput::setUpSmarty, as the call to addPluginsDir is also deprecated. The number of deprecation warnings this is throwing on every single page load isn't great. I think something like this is working, but I don't know for sure yet. There's probably a much better way to do it than this:

        $pluginsDir = $this->getSiteConfiguration()->getFilePath() . '/smarty-plugins';
//        $this->smarty->addPluginsDir($pluginsDir);

        /** @var DirectoryIterator $file */
        foreach (new DirectoryIterator($pluginsDir) as $file) {
            if ($file->isDot()) {
                continue;
            }

            if ($file->getExtension() != 'php') {
                continue;
            }

            require_once $file->getPathname();

            list($type, $name) = explode('.', $file->getBasename('.php'), 2);

            switch ($type) {
                case 'modifier':
                    $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, $name, 'smarty_modifier_' . $name);
                    break;
                case 'function':
                    $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, $name, 'smarty_function_' . $name);
                    break;
            }
        }

I've also looked at the ban list on /internal.php/bans, and that's actually properly broken too.

Exception 0: Smarty\CompilerException

Syntax error in template "file:bans/list.tpl" on line 39 "{if $ban->getDuration() < time() && $ban->getDuration() !== null}<span class="badge badge-warning">Expired</span>{/if}" unknown modifier 'time'

#0 ./vendor/smarty/smarty/src/Compile/ModifierCompiler.php(74): Smarty\Compiler\Template->trigger_template_error('unknown modifie...', 39, true)
#1 ./vendor/smarty/smarty/src/Compiler/Template.php(498): Smarty\Compile\ModifierCompiler->compile(Array, Object(Smarty\Compiler\Template), Array)
#2 ./vendor/smarty/smarty/src/Compiler/Template.php(1383): Smarty\Compiler\Template->compileModifier(Array, NULL)
#3 ./vendor/smarty/smarty/src/Parser/TemplateParser.php(2726): Smarty\Compiler\Template->compileModifierInExpression('time', Array)
#4 ./vendor/smarty/smarty/src/Parser/TemplateParser.php(2902): Smarty\Parser\TemplateParser->yy_r149()
#5 ./vendor/smarty/smarty/src/Parser/TemplateParser.php(2997): Smarty\Parser\TemplateParser->yy_reduce(149)
#6 ./vendor/smarty/smarty/src/Compiler/Template.php(1269): Smarty\Parser\TemplateParser->doParse(53, ' && ')
#7 ./vendor/smarty/smarty/src/Compiler/Template.php(437): Smarty\Compiler\Template->doCompile('

I've not spent a decent amount of time testing this yet, so there may be more things to be uncovered.

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

Successfully merging this pull request may close these issues.

2 participants