Project - Upgrade Smarty2 to Smarty3

A minor, albeit critical part of the codebase uses Smarty. The goal of this project is to migrate this code from using Smarty version 2 to Smarty version 3. This is critical for “future proofing” of OpenEMR’s codebase since Smarty version 2 will be deprecated in the future.

Mentors:
@brady.miller
@robertovasquez

Hi @brady.miller do we have an inventory of the scripts that need to upgraded? I will grep the smarty variables and I’ll start from there

hi @robertovasquez, please see this

What is Smarty?

Smarty is a template engine for PHP. Many other template engines for PHP
provide basic variable substitution and dynamic block functionality.
Smarty takes a step further to be a "smart" template engine, adding
features such as configuration files, template functions, and variable
modifiers, and making all of this functionality as easy as possible to
use for both programmers and template designers. Smarty also converts
the templates into PHP scripts, eliminating the need to parse the
templates on every invocation. This makes Smarty extremely scalable and
manageable for large application needs.

Some of Smarty's features:

* it is extremely fast
* no template parsing overhead, only compiles once.
    * it is smart about recompiling only the template files that have
      changed.
* the template language is remarkably extensible via the plugin
  architecture.
* configurable template delimiter tag syntax, so you can use
  {}, {{}}, <!--{}-->, or whatever you like.
* built-in caching of template output.
* arbitrary template sources (filesystem, databases, etc.)
* template if/elseif/else/endif constructs are passed to the PHP parser,
  so the if syntax can be as simple or as complex as you like.
* unlimited nesting of sections, conditionals, etc. allowed
* it is possible to embed PHP code right in your template files,
  although not recommended and doubtfully needed since the engine
  is so customizable.
* and many more.

Hi mentors,
I have done some work on updrading smarty2 to smarty3 a few years back when i was a begineer in development field and would love to work on this if it’s urgent.

2 Likes

hi @im-Amitto ,

Check out this issue for more detailed discussion on this project:
Migrate Smarty 2 code to Smarty 3 · Issue #2330 · openemr/openemr · GitHub

there is a PR by @thesmallstar related to this here:
Smarty2 to smarty3[pr1] phpgacl admin (ongoing Testing) by thesmallstar · Pull Request #3049 · openemr/openemr · GitHub

Looks like it will involve some smarty2->3 migration along with smarty->twig conversion.

1 Like

Hello Team

This is just a thought on the same topic.

How about migrating out of smarty instead of upgrading it. We heard before from the community that Smarty calendar has more performance issues when it has high load.

If so, we need to brainstorm on what will be the alternative and how complicated to replace.

Thank You
ViSolve-051

@visolveemr, yes we had some discussion over this here: Migrate Smarty 2 code to Smarty 3 · Issue #2330 · openemr/openemr · GitHub
Just after migrating to smarty3(guarantees long term support) we can start working on a robust and fast solution for calender.

What do you think on this approach?