jtmorris/phpframework — Issue #1: Configuration Settings Won't Update Until Session Expires/Ends
Author: jtmorris
Created: 2011-12-12 02:28:25+00:00
State: open

Where:
source/core/pf_dbinterface.php -> class Pf_dbinterface -> function __construct()

Problem:
Configuration settings are loaded into $_SESSION['pf_db']['config'], and then not reloaded until the user's session dies.

Why It's Bad
If the developer changes the config file, the changes will not be immediately used by all. Imagine someone leaving their browser open for days after visiting the website, and then returning. If the developer switched to a new database or something, then the user will still be trying to contact the old database.

Possible Solutions

Load the config each time the constructor is called. Bad because loading the config takes more time and memory than the current method

Reload config if a certain period of time has elapsed (i.e. if 15 minutes have passed since last config loading, reload it). Better than reloading each time, but still has a delay before all users obey new rules.

Store last update time in a variable in config file, and if that time is more recent than when config was loaded, reload it. Better than loading the whole config (Normal loading copies an array when loading, this could avoid that) each time, but the config file still must be opened and examined each time.

How Bad?
Very Bad. Could interfere with security of database (if it's compromised, changing login credentials can't close a security breach). Could break usability if developer doesn't factor this in to setting changes.