Skip to content

System: retire old functions in functions.php #1689

@yookoala

Description

@yookoala

Problem

There are roughly 4 types of functions in functions.php:

  1. Old style database reading functions with old school $guid and/or $connection2 (\PDO) as parameter.
  2. HTML element rendering.
  3. Utility functions for formatting (e.g. email body sanitation) or other helper functions (e.g. resolving client IP address).
  4. Shortcut for accessing core service feature (e.g. __(), __n(), __m()).

The first type of function cause usage of all the global $guid and $connection2, which is an anti-pattern when transiting to service container architecture.

Proposed Solution

  1. The first type should be rewritten into Gateway service method (or, in some case, rewritten as service provider).
  2. The second type should be rewritten into Form component or other Outputable class.
  3. The thrid type can be rewritten as static methods of some utility classes.
  4. The forth type can be left as-is for now.

In the rewrite, all obsoleted functions should not be removed for now. Instead, they are to be marked deprecated in their phpdocs doc-block. Modern IDE (e.g. VSCode) will identify the deprecated function calls and warn developers.

Alternatives

Leaving things as-is.

Additional Context

Functions to refactor:

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions