$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if($stored < $current) {
- load_config('database');
+ Config::load('database');
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
--
CREATE TABLE IF NOT EXISTS `addon` (
`id` int(11) NOT NULL auto_increment,
- `name` varchar(255) NOT NULL DEFAULT '',
+ `name` varchar(190) NOT NULL DEFAULT '',
`version` varchar(255) NOT NULL DEFAULT '',
`installed` tinyint(1) NOT NULL DEFAULT 0,
`hidden` tinyint(1) NOT NULL DEFAULT 0,
`timestamp` bigint(20) NOT NULL DEFAULT 0,
`plugin_admin` tinyint(1) NOT NULL DEFAULT 0,
- PRIMARY KEY(`id`)
+ PRIMARY KEY(`id`),
+ UNIQUE INDEX `name` (`name`)
) DEFAULT CHARSET=utf8mb4;
--
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`allow_cid` mediumtext,
- `allow_gid` medium_text,
- `deny_cid` medium_text,
- `deny_gid` medium_text,
+ `allow_gid` mediumtext,
+ `deny_cid` mediumtext,
+ `deny_gid` mediumtext,
PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4;
`nofinish` tinyint(1) NOT NULL DEFAULT 0,
`adjust` tinyint(1) NOT NULL DEFAULT 1,
`ignore` tinyint(1) unsigned NOT NULL DEFAULT 0,
- `allow_cid` medium_text,
- `allow_gid` medium_text,
- `deny_cid` medium_text,
- `deny_gid` medium_text,
+ `allow_cid` mediumtext,
+ `allow_gid` mediumtext,
+ `deny_cid` mediumtext,
+ `deny_gid` mediumtext,
PRIMARY KEY(`id`),
INDEX `uid_start` (`uid`,`start`)
) DEFAULT CHARSET=utf8mb4;
`function` varchar(255) NOT NULL DEFAULT '',
`priority` int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY(`id`),
- INDEX `hook_file_function` (`hook`(30),`file`(60),`function`(30))
+ UNIQUE INDEX `hook_file_function` (`hook`(50),`file`(80),`function`(60))
) DEFAULT CHARSET=utf8mb4;
--
`expire_notification_sent` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`service_class` varchar(32) NOT NULL DEFAULT '',
`def_gid` int(11) NOT NULL DEFAULT 0,
- `allow_cid` medium_text,
- `allow_gid` medium_text,
- `deny_cid` medium_text,
- `deny_gid` medium_text,
+ `allow_cid` mediumtext,
+ `allow_gid` mediumtext,
+ `deny_cid` mediumtext,
+ `deny_gid` mediumtext,
`openidserver` text,
PRIMARY KEY(`uid`),
INDEX `nickname` (`nickname`(32))
*/
class Config {
+ private static $cache;
+
/**
* @brief Loads all configuration values of family into a cached storage.
*
* The category of the configuration value
* @return void
*/
- public static function load($family) {
+ public static function load($family = "config") {
+
+ // We don't preload "system" anymore.
+ // This reduces the number of database reads a lot.
+ if ($family == 'system') {
+ return;
+ }
+
$a = get_app();
- $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
+ $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$k = $rr['k'];
$a->config[$k] = $rr['v'];
} else {
$a->config[$family][$k] = $rr['v'];
+ self::$cache[$family][$k] = $rr['v'];
}
}
- } else if ($family != 'config') {
- // Negative caching
- $a->config[$family] = "!<unset>!";
}
}
$a = get_app();
if (!$refresh) {
- // Looking if the whole family isn't set
- if (isset($a->config[$family])) {
- if ($a->config[$family] === '!<unset>!') {
- return $default_value;
- }
- }
- if (isset($a->config[$family][$key])) {
- if ($a->config[$family][$key] === '!<unset>!') {
+ // Do we have the cached value? Then return it
+ if (isset(self::$cache[$family][$key])) {
+ if (self::$cache[$family][$key] == '!<unset>!') {
return $default_value;
+ } else {
+ return self::$cache[$family][$key];
}
- return $a->config[$family][$key];
}
}
- $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
+ $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
dbesc($family),
dbesc($key)
);
- if (count($ret)) {
+ if (dbm::is_result($ret)) {
// manage array value
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
- $a->config[$family][$key] = $val;
+ // Assign the value from the database to the cache
+ self::$cache[$family][$key] = $val;
return $val;
- } else {
- $a->config[$family][$key] = '!<unset>!';
+ } elseif (isset($a->config[$family][$key])) {
+
+ // Assign the value (mostly) from the .htconfig.php to the cache
+ self::$cache[$family][$key] = $a->config[$family][$key];
+
+ return $a->config[$family][$key];
}
+
+ self::$cache[$family][$key] = '!<unset>!';
+
return $default_value;
}
return true;
}
- $a->config[$family][$key] = $value;
+ if ($family === 'config') {
+ $a->config[$key] = $value;
+ } elseif ($family != 'system') {
+ $a->config[$family][$key] = $value;
+ }
+
+ // Assign the just added value to the cache
+ self::$cache[$family][$key] = $value;
// manage array value
$dbvalue = (is_array($value) ? serialize($value) : $value);
*/
public static function delete($family, $key) {
- $a = get_app();
- if (x($a->config[$family],$key)) {
- unset($a->config[$family][$key]);
+ if (isset(self::$cache[$family][$key])) {
+ unset(self::$cache[$family][$key]);
}
$ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
dbesc($family),
return $ret;
}
-
}
<?php /** @file */
+use \Friendica\Core\Config;
+
require_once('boot.php');
// Everything we need to boot standalone 'background' processes
global $a, $db;
- if(is_null($a)) {
+ if (is_null($a)) {
$a = new App;
}
- if(is_null($db)) {
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
+ if (is_null($db)) {
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
};
require_once('include/session.php');
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
*
* This script is started from mod/item.php to save some time when doing a post.
*/
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/threads.php");
unset($db_host, $db_user, $db_pass, $db_data);
}
- load_config('config');
- load_config('system');
+ Config::load();
if ($argc != 2) {
return;
chdir($directory);
}
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/photos.php");
require_once("include/user.php");
require_once('mod/nodeinfo.php');
require_once('include/post_update.php');
- load_config('config');
- load_config('system');
+ Config::load();
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
<?php
-require_once("boot.php");
+use \Friendica\Core\Config;
+require_once("boot.php");
function cronhooks_run(&$argv, &$argc){
global $a, $db;
require_once('include/session.php');
require_once('include/datetime.php');
- load_config('config');
- load_config('system');
+ Config::load();
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
<?php
+use \Friendica\Core\Config;
+
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
require_once('include/post_update.php');
require_once('mod/nodeinfo.php');
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
unset($db_host, $db_user, $db_pass, $db_data);
}
- Config::load('config');
- Config::load('system');
+ Config::load();
if (!Config::get('system', 'dbclean', false)) {
return;
$database["addon"] = array(
"fields" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
- "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+ "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
"version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
),
"indexes" => array(
"PRIMARY" => array("id"),
+ "name" => array("UNIQUE", "name"),
)
);
$database["attach"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "hook_file_function" => array("hook(30)","file(60)","function(30)"),
+ "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
)
);
$database["intro"] = array(
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
function dbupdate_run(&$argv, &$argc) {
unset($db_host, $db_user, $db_pass, $db_data);
}
- load_config('config');
- load_config('system');
+ Config::load();
update_db($a);
}
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
require_once('include/bbcode.php');
require_once('include/email.php');
- load_config('config');
- load_config('system');
+ Config::load();
load_hooks();
<?php
require_once("boot.php");
+use \Friendica\Core\Config;
+
function directory_run(&$argv, &$argc){
global $a, $db;
unset($db_host, $db_user, $db_pass, $db_data);
};
- load_config('config');
- load_config('system');
-
+ Config::load();
if($argc != 2)
return;
- load_config('system');
-
load_hooks();
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/socgraph.php");
-
function discover_poco_run(&$argv, &$argc){
global $a, $db;
require_once('include/session.php');
require_once('include/datetime.php');
- load_config('config');
- load_config('system');
+ Config::load();
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run")
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
function expire_run(&$argv, &$argc){
}
if(is_null($db)) {
- @include(".htconfig.php");
- require_once("include/dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
- };
+ @include(".htconfig.php");
+ require_once("include/dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
require_once('include/session.php');
require_once('include/datetime.php');
require_once('include/items.php');
require_once('include/Contact.php');
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once('include/Scrape.php');
require_once('include/socgraph.php');
require_once('include/session.php');
require_once('include/datetime.php');
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
require_once('include/items.php');
require_once('include/bbcode.php');
require_once('include/email.php');
- load_config('config');
- load_config('system');
+
+ Config::load();
load_hooks();
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/follow.php");
require_once('include/socgraph.php');
require_once('include/queue_fn.php');
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
require_once('include/items.php');
- load_config('config');
- load_config('system');
+ Config::load();
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/dfrn.php');
require_once('include/bbcode.php');
require_once('include/socgraph.php');
- load_config('config');
- load_config('system');
+ Config::load();
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run")
* @file include/remove_contact.php
* @brief Removes orphaned data from deleted contacts
*/
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
function remove_contact_run($argv, $argc) {
unset($db_host, $db_user, $db_pass, $db_data);
}
- load_config('config');
- load_config('system');
+ Config::load();
if ($argc != 2) {
return;
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/threads.php");
unset($db_host, $db_user, $db_pass, $db_data);
}
-load_config('config');
-load_config('system');
+Config::load();
update_shadow_copy();
killme();
* @file include/spool_post.php
* @brief Posts items that wer spooled because they couldn't be posted.
*/
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/items.php");
unset($db_host, $db_user, $db_pass, $db_data);
}
- load_config('config');
- load_config('system');
+ Config::load();
$path = get_spoolpath();
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/tags.php");
unset($db_host, $db_user, $db_pass, $db_data);
}
-load_config('config');
-load_config('system');
+Config::load();
update_items();
killme();
<?php
+
+use \Friendica\Core\Config;
+
require_once("boot.php");
require_once("include/threads.php");
unset($db_host, $db_user, $db_pass, $db_data);
}
-load_config('config');
-load_config('system');
+Config::load();
update_threads();
update_threads_mention();
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
function update_gcontact_run(&$argv, &$argc){
require_once('include/Scrape.php');
require_once("include/socgraph.php");
- load_config('config');
- load_config('system');
+ Config::load();
$a->set_baseurl(get_config('system','url'));
*
*/
+use \Friendica\Core\Config;
+
require_once('boot.php');
require_once('object/BaseObject.php');
* Load configs from db. Overwrite configs from .htconfig.php
*/
- load_config('config');
- load_config('system');
+ Config::load();
if ($a->max_processes_reached() OR $a->maxload_reached()) {
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
<?php
+use \Friendica\Core\Config;
+
function friendica_init(App $a) {
if ($a->argv[1]=="json"){
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$visible_plugins[] = $rr['name'];
}
- load_config('feature_lock');
+ Config::load('feature_lock');
$locked_features = array();
if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
foreach($a->config['feature_lock'] as $k => $v) {
<?php
+use \Friendica\Core\Config;
+
require_once("boot.php");
$a = new App;
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data, false);
- unset($db_host, $db_user, $db_pass, $db_data);
-load_config('config');
-load_config('system');
+unset($db_host, $db_user, $db_pass, $db_data);
+
+Config::load();
$maint_mode = 1;
if($argc > 1)