Merge remote-tracking branch 'upstream/3.5.2rc' into 1705-dbclean-advanced

This commit is contained in:
Michael
2017-05-29 20:54:43 +00:00
14 changed files with 34042 additions and 33704 deletions
+10
View File
@@ -8,6 +8,10 @@ require_once("include/text.php");
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
const DB_UPDATE_FAILED = 2; // Database check failed
/*
* Converts all tables from MyISAM to InnoDB
*/
@@ -480,6 +484,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
Config::set('system', 'maintenance_reason', '');
}
if ($errors) {
Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
} else {
Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
}
return $errors;
}
+30 -24
View File
@@ -417,11 +417,9 @@ function poller_too_much_workers() {
$maxqueues = $queues;
$active = poller_active_workers();
// Decrease the number of workers at higher load
$load = current_load();
if($load) {
if ($load) {
$maxsysload = intval(Config::get("system", "maxloadavg", 50));
$maxworkers = $queues;
@@ -431,6 +429,33 @@ function poller_too_much_workers() {
$slope = $maxworkers / pow($maxsysload, $exponent);
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
$active = 0;
// Create a list of queue entries grouped by their priority
$listitem = array();
// Adding all processes with no workerqueue entry
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS (SELECT id FROM `workerqueue` WHERE `workerqueue`.`pid` = `process`.`pid`)");
if ($process = dba::fetch($processes)) {
$listitem[0] = "0:".$process["running"];
$active += $process["running"];
}
dba::close($processes);
// Now adding all processes with workerqueue entries
$entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
while ($entry = dba::fetch($entries)) {
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` LEFT JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE `priority` = ?", $entry["priority"]);
if ($process = dba::fetch($processes)) {
$listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
$active += $process["running"];
}
dba::close($processes);
}
dba::close($entries);
$processlist = implode(', ', $listitem);
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
$entries = $s[0]["total"];
@@ -448,27 +473,6 @@ function poller_too_much_workers() {
}
}
// Create a list of queue entries grouped by their priority
$running = array(PRIORITY_CRITICAL => 0,
PRIORITY_HIGH => 0,
PRIORITY_MEDIUM => 0,
PRIORITY_LOW => 0,
PRIORITY_NEGLIGIBLE => 0);
$r = q("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` GROUP BY `priority`");
if (dbm::is_result($r))
foreach ($r AS $process)
$running[$process["priority"]] = $process["running"];
$processlist = "";
$r = q("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
if (dbm::is_result($r))
foreach ($r as $entry) {
if ($processlist != "")
$processlist .= ", ";
$processlist .= $entry["priority"].":".$running[$entry["priority"]]."/".$entry["entries"];
}
logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries." (".$processlist.") - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
// Are there fewer workers running as possible? Then fork a new one.
@@ -478,6 +482,8 @@ function poller_too_much_workers() {
$a = get_app();
$a->proc_run($args);
}
} else {
$active = poller_active_workers();
}
return($active >= $queues);
+9 -4
View File
@@ -545,11 +545,16 @@ function admin_page_summary(App $a) {
$showwarning = true;
$warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php include/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
}
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$warningtext[] = t('You are using a MySQL version which does not support all features that Friendica uses. You should consider switching to MariaDB.');
if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) {
require_once("include/dbstructure.php");
update_structure(false, true);
}
if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) {
$showwarning = true;
$warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.');
}
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = array(
array(t('Normal Account'), 0),
+1
View File
@@ -4,6 +4,7 @@ use Friendica\App;
use Friendica\Network\Probe;
require_once 'include/Contact.php';
require_once 'include/socgraph.php';
function profiles_init(App $a) {
+30 -1
View File
@@ -58,6 +58,28 @@ class Probe {
return $newdata;
}
/**
* @brief Check if the hostname belongs to the own server
*
* @param string $host The hostname that is to be checked
*
* @return bool Does the testes hostname belongs to the own server?
*/
private function ownHost($host) {
$own_host = get_app()->get_hostname();
$parts = parse_url($host);
if (!isset($parts['scheme'])) {
$parts = parse_url('http://'.$host);
}
if (!isset($parts['host'])) {
return false;
}
return $parts['host'] == $own_host;
}
/**
* @brief Probes for XRD data
*
@@ -82,7 +104,8 @@ class Probe {
logger("Probing for ".$host, LOGGER_DEBUG);
$ret = z_fetch_url($ssl_url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml'));
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
if (($ret['errno'] == CURLE_OPERATION_TIMEDOUT) AND !self::ownHost($ssl_url)) {
logger("Probing timeout for ".$ssl_url, LOGGER_DEBUG);
return false;
}
$xml = $ret['body'];
@@ -92,12 +115,14 @@ class Probe {
if (!is_object($xrd)) {
$ret = z_fetch_url($url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml'));
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
logger("Probing timeout for ".$url, LOGGER_DEBUG);
return false;
}
$xml = $ret['body'];
$xrd = parse_xml_string($xml, false);
}
if (!is_object($xrd)) {
logger("No xrd object found for ".$host, LOGGER_DEBUG);
return false;
}
@@ -133,6 +158,8 @@ class Probe {
self::$baseurl = "http://".$host;
logger("Probing successful for ".$host, LOGGER_DEBUG);
return $xrd_data;
}
@@ -404,6 +431,7 @@ class Probe {
$lrdd = self::xrd($host);
}
if (!$lrdd) {
logger('No XRD data was found for '.$uri, LOGGER_DEBUG);
return self::feed($uri);
}
$nick = array_pop($path_parts);
@@ -435,6 +463,7 @@ class Probe {
$lrdd = self::xrd($host);
if (!$lrdd) {
logger('No XRD data was found for '.$uri, LOGGER_DEBUG);
return self::mail($uri, $uid);
}
$addr = $uri;
+5955 -5953
View File
File diff suppressed because it is too large Load Diff
+6232 -6229
View File
File diff suppressed because it is too large Load Diff
+1170 -1170
View File
File diff suppressed because it is too large Load Diff
+6381 -6378
View File
File diff suppressed because it is too large Load Diff
+1210 -1210
View File
File diff suppressed because it is too large Load Diff
+6088 -5965
View File
File diff suppressed because it is too large Load Diff
+1398 -1366
View File
File diff suppressed because it is too large Load Diff
+4651 -4550
View File
File diff suppressed because it is too large Load Diff
+877 -854
View File
File diff suppressed because it is too large Load Diff