Create intermediate class to access /system/config.php file

Components

Labels

Description

File /system/config.php is created during In-Portal installation and contains all core settings that are needed to be able to run In-Portal.
For example it contains database connection information. Then once connected to database In-Portal can get other settings from there.

This file very powerful, however code that uses it is scattered across the system. For example there is:

  • kUtil::parseVars method, that returns contents of that file as array (used each time)

  • some pieces of code in /core/kernel/startup.php file, that ensures default values for some settings, that might be missing (used each time)

  • some pieces of code in /core/install.php file, that ensures default values for some other settings, that might be missing (used during install)

I'm proposing to create kSystemConfig class, that can be accessed from everywhere (due his static nature) and will ensure that all settings have their default values and can be accessed properly.

Context Information

None

Additional information (do not use)

Constants, that are defined based on /system/config.php file contents, like SQL_DB, ADMIN_DIRECTORY can stay of course.

Attachments

4

Activity

[API] Administrator September 3, 2013 at 3:14 PM

User committed a fix to 5.3.x. Commit Message:

Fixes - Create intermediate class to access /system/config.php file

Alex September 3, 2013 at 3:12 PM

Errors:

  1. fixed static method declarations

  2. error message about missing config was now longer displayed

  3. fatal error on license upload during installation

  4. default value for CompressionEngine setting was missing, resulting in a notice

  5. typo error, resulting in warning during final installation step

Other:

  1. restored removed comments in install.php

All of above was fixed in v4 patch.

Erik S. August 27, 2013 at 12:23 PM

All requested changes done. New patch attached -
class_to_access_config_php_file_v2.patch 44 kB

Ready for Testing

Alex July 30, 2013 at 6:37 PM

Quick glance on the patch revealed this things:

  1. file system_config.php should be located under /core/kernel/utility/ folder

  2. upon class creation (in constructor) an optional path to "config.php" file can be specified; if not specified then default one is used

  3. class methods must not be static

  4. add static kUtil::getSystemConfig method, that would instantiate kSystemConfig class once and store locally in protected kUtil::systemConfig class variable

  5. methods for writing/reading variables from/to file should be added in kSystemConfig class too

  6. changes to default values:

    1. data, read from config (by calling parseConfig method) would be stored in new $data class variable

    2. this $data config variable would have a default values in it by default (set from class constructor)

  7. method name getConfigVars doesn't fit in kSystemConfig class ("config" word used 2 times) and should be renamed to getData

  8. with parsed config data stored locally in $data class variable there is no need to store data in the static variable as it was done before.

Erik S. July 23, 2013 at 12:58 PM

All done. Attached patch class_to_access_config_php_file.patch 23/Jul/13 3:57 PM 16 kB. Ready for testing.

Fixed

Details

Priority

Assignee

Reporter

Developer

Reviewer

Change Log Group

Added

Change Log Message

Patch Instructions

Patches must be submitted through Phabricator.

Commit Revision

15,962

External issue ID

Story Points

Fix versions

Affects versions

Created September 16, 2012 at 6:03 PM
Updated December 29, 2024 at 8:58 PM
Resolved September 3, 2013 at 3:14 PM