aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--Zotlabs/Lib/Config.php87
-rw-r--r--Zotlabs/Lib/Libzot.php15
-rw-r--r--Zotlabs/Module/Appman.php10
4 files changed, 75 insertions, 39 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fc3eb7f6b..b8893c32b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,6 @@
Hubzilla 8.8.2 (2023-12-06)
- Fix missing includes - issue #1820
- - Addon logger_stats: mproved performance reading big log files
+ - Addon logger_stats: improved performance reading big log files
Hubzilla 8.8.1 (2023-11-27)
diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php
index c00b8efb6..40d5cc246 100644
--- a/Zotlabs/Lib/Config.php
+++ b/Zotlabs/Lib/Config.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Lib;
+use App;
class Config {
@@ -14,21 +15,44 @@ class Config {
* @param string $family
* The category of the configuration value
*/
- static public function Load($family) {
- if(! array_key_exists($family, \App::$config))
- \App::$config[$family] = array();
+ public static function Load($family, $recursionCounter = 0) {
+ if (! array_key_exists($family, App::$config)) {
+ App::$config[$family] = [];
+ }
+
+ // We typically continue when presented with minor DB issues,
+ // but loading the site configuration is more important.
+
+ // Check for query returning false and give it approx 30 seconds
+ // to recover if there's a problem. This is intended to fix a
+ // rare issue on Galera where temporary sync issues were causing
+ // the site encryption keys to be regenerated, which was causing
+ // communication issues for members.
+
+ // This code probably belongs at the database layer, but we don't
+ // necessarily want to shut the site down for problematic queries
+ // caused by bad data. That could be used in a denial of service
+ // attack. Those do need to be (and they are) logged.
- if(! array_key_exists('config_loaded', \App::$config[$family])) {
+ if (! array_key_exists('config_loaded', App::$config[$family])) {
$r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family));
- if($r !== false) {
- if($r) {
- foreach($r as $rr) {
- $k = $rr['k'];
- \App::$config[$family][$k] = $rr['v'];
- }
+ if ($r === false) {
+ sleep(3);
+ $recursionCounter ++;
+ if ($recursionCounter > 10) {
+ system_unavailable();
}
- \App::$config[$family]['config_loaded'] = true;
+ self::Load($family, $recursionCounter);
}
+ else {
+ foreach ($r as $rr) {
+ $k = $rr['k'];
+ App::$config[$family][$k] = $rr['v'];
+ }
+ App::$config[$family]['config_loaded'] = true;
+ }
+
+
}
}
@@ -46,19 +70,19 @@ class Config {
* @return mixed
* Return the set value, or false if the database update failed
*/
- static public function Set($family, $key, $value) {
+ public static function Set($family, $key, $value) {
// manage array value
- $dbvalue = ((is_array($value)) ? serialize($value) : $value);
+ $dbvalue = ((is_array($value)) ? serialise($value) : $value);
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
- if(self::Get($family, $key) === false || (! self::get_from_storage($family, $key))) {
+ if (self::Get($family, $key) === false || (! self::get_from_storage($family, $key))) {
$ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
dbesc($dbvalue)
);
- if($ret) {
- \App::$config[$family][$key] = $value;
+ if ($ret) {
+ App::$config[$family][$key] = $value;
$ret = $value;
}
return $ret;
@@ -70,8 +94,8 @@ class Config {
dbesc($key)
);
- if($ret) {
- \App::$config[$family][$key] = $value;
+ if ($ret) {
+ App::$config[$family][$key] = $value;
$ret = $value;
}
@@ -96,18 +120,21 @@ class Config {
* @param string $default (optional) default false
* @return mixed Return value or false on error or if not set
*/
- static public function Get($family, $key, $default = false) {
- if((! array_key_exists($family, \App::$config)) || (! array_key_exists('config_loaded', \App::$config[$family])))
+ public static function Get($family, $key, $default = false) {
+ if ((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) {
self::Load($family);
+ }
- if(array_key_exists('config_loaded', \App::$config[$family])) {
- if(! array_key_exists($key, \App::$config[$family])) {
+ if (array_key_exists('config_loaded', App::$config[$family])) {
+ if (! array_key_exists($key, App::$config[$family])) {
return $default;
}
- return ((! is_array(\App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$family][$key]))
- ? unserialize(\App::$config[$family][$key])
- : \App::$config[$family][$key]
+
+ return ((! is_array(App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$family][$key]))
+ ? unserialize(App::$config[$family][$key])
+ : App::$config[$family][$key]
);
+
}
return $default;
@@ -125,12 +152,13 @@ class Config {
* The configuration key to delete
* @return mixed
*/
- static public function Delete($family, $key) {
+ public static function Delete($family, $key) {
$ret = false;
- if(array_key_exists($family, \App::$config) && array_key_exists($key, \App::$config[$family]))
- unset(\App::$config[$family][$key]);
+ if (array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) {
+ unset(App::$config[$family][$key]);
+ }
$ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'",
dbesc($family),
@@ -153,7 +181,7 @@ class Config {
* The configuration key to query
* @return mixed
*/
- static private function get_from_storage($family,$key) {
+ private static function get_from_storage($family, $key) {
$ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1",
dbesc($family),
dbesc($key)
@@ -161,5 +189,4 @@ class Config {
return $ret;
}
-
}
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index e9cb2c35c..3f8685397 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1234,17 +1234,16 @@ class Libzot {
if ($z) {
$r = Activity::get_actor_hublocs($author_url);
}
- }
- if ($r) {
- $r = self::zot_record_preferred($r);
- $item['author_xchan'] = $r['hubloc_hash'];
+ if (!$r) {
+ logger('Could not fetch author');
+ return;
+ }
}
- if (! $item['author_xchan']) {
- logger('No author!');
- return;
- }
+ $r = self::zot_record_preferred($r);
+
+ $item['author_xchan'] = $r['hubloc_hash'];
$item['owner_xchan'] = $env['sender'];
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index 34f5f453d..5f72d771b 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -110,6 +110,11 @@ class Appman extends \Zotlabs\Web\Controller {
dbesc($papp['guid'])
);
+ $sync[0]['term'] = q("select * from term where otype = %d and oid = %d",
+ intval(TERM_OBJ_APP),
+ intval($sync[0]['id'])
+ );
+
if (intval($sync[0]['app_system'])) {
Libsync::build_sync_packet(local_channel(), ['sysapp' => $sync]);
}
@@ -126,6 +131,11 @@ class Appman extends \Zotlabs\Web\Controller {
dbesc($papp['guid'])
);
+ $sync[0]['term'] = q("select * from term where otype = %d and oid = %d",
+ intval(TERM_OBJ_APP),
+ intval($sync[0]['id'])
+ );
+
if (intval($sync[0]['app_system'])) {
Libsync::build_sync_packet(local_channel(), ['sysapp' => $sync]);
}