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

Do not use F3 for configuration management #1261

Merged
merged 5 commits into from
Apr 27, 2021
Merged

Do not use F3 for configuration management #1261

merged 5 commits into from
Apr 27, 2021

Commits on Apr 27, 2021

  1. Do not use F3 for configuration management

    Fatfree is badly designed and should not have lived past 2005. Most notably, it relies on a single huge singleton object, which makes testing difficult. What is worse, the unholy things it does to error handling makes PHPStan and PHPUnit crash. For these reasons and other pains, selfoss will be gradually removing its use. Configuration values are read throughout the codebase so I decided to tackle those first.
    
    Ideally, we would construct a configuration container using something like <https://gitlab.com/Khartir/typed-config> but that requires more recent PHP version than we support. Other configuration libraries either suffer from the same problem, are untyped like f3 was (domains of the options are known so we should not have to cast the string loaded from the ini file at the point of use), or are completely undocumented. Custom solution had to be implemented.
    
    This patch adds `helpers\Configuration` class, which will load data from `config.ini` and environment variables and store them in properties. The class is injected by Dice into whichever other class that needs access to configuration. In addition to reducing the percentage of code paths tainted by F3,
    it will also bring better developer experience since editors and other tools can make use of the property annotations.
    
    Since the default values of configuration option are now stored as default values of the class properties, `defaults.ini` is no longer used. It will still be included in the distribution zipball for convenience (generated from the code.
    
    In the future, we can move the option descriptions into the class and have the options documentation generated as well.
    jtojnar committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    1f194f8 View commit details
    Browse the repository at this point in the history
  2. Fix various issues discovered by PHPStan

    while validating the changes from the previous commit.
    jtojnar committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    c5ba500 View commit details
    Browse the repository at this point in the history
  3. docs: Document WordPress sharer

    It requires an extra option so let’s warn about that. And also do the same for wallabag.
    jtojnar committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    6907986 View commit details
    Browse the repository at this point in the history
  4. config: Default to Wallabag 2

    It has been years since Wallabag 2 has been released so let’s allow people to remove wallabag_version=2 from their configs by making it the default value. This is potentially breaking change but hopefully, no one uses Wallabag 1 any more.
    jtojnar committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    b223ef5 View commit details
    Browse the repository at this point in the history
  5. server: Move constants to a separate file

    This will allow us to share them with tests and also make PHPStan aware of them.
    jtojnar committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    d1ca410 View commit details
    Browse the repository at this point in the history