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

Meta: retire old functions in functions.php #1689

Open
25 of 48 tasks
yookoala opened this issue Oct 28, 2022 · 1 comment
Open
25 of 48 tasks

Meta: retire old functions in functions.php #1689

yookoala opened this issue Oct 28, 2022 · 1 comment

Comments

@yookoala
Copy link
Member

yookoala commented Oct 28, 2022

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:

@SKuipers
Copy link
Member

SKuipers commented Nov 4, 2022

Amazing, thanks for getting this initiative underway and documenting it so well 😃

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

No branches or pull requests

2 participants