From 04a7d6384ef5ae137019286c3819fef1d5afcf6b Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:27:38 +0100 Subject: [PATCH 1/7] No need to set $a->theme_info = array() everywhere if you can define it in App itself. Signed-off-by: Roland Haeder --- boot.php | 5 +++-- view/theme/decaf-mobile/theme.php | 1 - view/theme/duepuntozero/theme.php | 1 - view/theme/facepark/theme.php | 1 - view/theme/frost-mobile/theme.php | 1 - view/theme/frost/theme.php | 1 - view/theme/quattro/theme.php | 2 -- view/theme/smoothly/theme.php | 1 - view/theme/vier/theme.php | 2 -- 9 files changed, 3 insertions(+), 12 deletions(-) diff --git a/boot.php b/boot.php index d82669f23..4b2e83f18 100644 --- a/boot.php +++ b/boot.php @@ -465,11 +465,12 @@ class App { public $plugins; public $apps = array(); public $identities; - public $is_mobile; - public $is_tablet; + public $is_mobile = false; + public $is_tablet = false; public $is_friendica_app; public $performance = array(); public $callstack = array(); + public $theme_info = array(); public $nav_sel; diff --git a/view/theme/decaf-mobile/theme.php b/view/theme/decaf-mobile/theme.php index 1a32fb724..9b1c1daa6 100644 --- a/view/theme/decaf-mobile/theme.php +++ b/view/theme/decaf-mobile/theme.php @@ -10,7 +10,6 @@ */ function decaf_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index ba3f25d3e..50d57f91e 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -2,7 +2,6 @@ function duepuntozero_init(&$a) { -$a->theme_info = array(); set_template_engine($a, 'smarty3'); $colorset = get_pconfig( local_user(), 'duepuntozero','colorset'); diff --git a/view/theme/facepark/theme.php b/view/theme/facepark/theme.php index e7203c664..e6255f118 100644 --- a/view/theme/facepark/theme.php +++ b/view/theme/facepark/theme.php @@ -1,7 +1,6 @@ theme_info = array(); set_template_engine($a, 'smarty3'); $a->page['htmlhead'] .= <<< EOT diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index beec92493..29a990f7b 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -10,7 +10,6 @@ */ function frost_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 868a840de..1093a0472 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -10,7 +10,6 @@ */ function frost_init(&$a) { - $a->theme_info = array(); $a->videowidth = 400; $a->videoheight = 330; $a->theme_thread_allow = false; diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index a1cd29ee7..0b67c6b49 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -8,8 +8,6 @@ */ function quattro_init(&$a) { - $a->theme_info = array(); - $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index d3ebbc1d1..0dae3a6e4 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -11,7 +11,6 @@ */ function smoothly_init(&$a) { - $a->theme_info = array(); set_template_engine($a, 'smarty3'); $cssFile = null; diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7f6ead079..925ac76a1 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -19,8 +19,6 @@ function vier_init(&$a) { set_template_engine($a, 'smarty3'); - $a->theme_info = array(); - if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) { vier_community_info(); From f10d2afca0edfef804aa95affe77bba99a603b3b Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:32:19 +0100 Subject: [PATCH 2/7] Prevent some E_NOTICE in boot.php Signed-off-by: Roland Haeder --- boot.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/boot.php b/boot.php index d82669f23..44fbcda73 100644 --- a/boot.php +++ b/boot.php @@ -1046,11 +1046,21 @@ class App { function save_timestamp($stamp, $value) { $duration = (float)(microtime(true)-$stamp); + if (!isset($this->performance[$value])) { + // Prevent ugly E_NOTICE + $this->performance[$value] = 0; + } + $this->performance[$value] += (float)$duration; $this->performance["marktime"] += (float)$duration; $callstack = $this->callstack(); + if (!isset($this->callstack[$value][$callstack])) { + // Prevent ugly E_NOTICE + $this->callstack[$value][$callstack] = 0; + } + $this->callstack[$value][$callstack] += (float)$duration; } From 04eacb64703c8d2a590c64da7ed5fae80ac26769 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:36:23 +0100 Subject: [PATCH 3/7] Prevent some E_NOTICE in identity.php Signed-off-by: Roland Haeder --- include/identity.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/identity.php b/include/identity.php index aba69bae4..888a09ee6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -237,6 +237,7 @@ function profile_sidebar($profile, $block = 0) { if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect'])) $connect = false; + $remoteconnect = NULL; if (isset($profile['remoteconnect'])) $remoteconnect = $profile['remoteconnect']; @@ -292,9 +293,9 @@ function profile_sidebar($profile, $block = 0) { // check if profile is a forum if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP) - || (intval($profile['forum'])) - || (intval($profile['prv'])) - || (intval($profile['community']))) + || (isset($profile['forum']) && intval($profile['forum'])) + || (isset($profile['prv']) && intval($profile['prv'])) + || (isset($profile['community']) && intval($profile['community']))) $account_type = t('Forum'); else $account_type = ""; From 8616f0cc3526b0f0ca3d16800984e118c5d56d94 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:07 +0100 Subject: [PATCH 4/7] Don't miss to add exit() after header('Location: bla') as header() does *NOT* exit the script quickly enough. Always use an explicit exit() or you get real trouble. Signed-off-by: Roland Haeder --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index e364389b2..625c2d82d 100644 --- a/index.php +++ b/index.php @@ -72,7 +72,8 @@ if(!$install) { (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (substr($a->get_baseurl(), 0, 8) == "https://")) { header("HTTP/1.1 302 Moved Temporarily"); - header("location: ".$a->get_baseurl()."/".$a->query_string); + header("Location: ".$a->get_baseurl()."/".$a->query_string); + exit(); } require_once("include/session.php"); From 08abdfda684c6b9215109da6f999351f81c00ac3 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:56 +0100 Subject: [PATCH 5/7]
and or are not self-closing tags. Signed-off-by: Roland Haeder --- view/templates/dfrn_request.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/templates/dfrn_request.tpl b/view/templates/dfrn_request.tpl index 3b96d3eef..5225bd60b 100644 --- a/view/templates/dfrn_request.tpl +++ b/view/templates/dfrn_request.tpl @@ -18,13 +18,13 @@ {{/if}} {{if $request}} - + {{else}} - + {{/if}} {{if $photo}} - + {{/if}} {{if $url}}
{{$url_label}}
{{$url}}
{{/if}} From ce5f6fae51ac6c246bb0371798994bef7e589d42 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 1 Mar 2016 19:14:45 +0100 Subject: [PATCH 6/7] Small bugfix: Fixes problen when version number contains linebreaks --- mod/admin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index 7a16820c4..a98f464f8 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -283,14 +283,14 @@ function admin_page_federation(&$a) { // get a total count for the platform, the name and version of the // highest version and the protocol tpe $c = q('SELECT count(*) AS total, platform, network, version FROM gserver - WHERE platform LIKE "%s" AND last_contact > last_failure + WHERE platform LIKE "%s" AND last_contact > last_failure AND `version` != "" ORDER BY version ASC;', $p); $total = $total + $c[0]['total']; // what versions for that platform do we know at all? // again only the active nodes $v = q('SELECT count(*) AS total, version FROM gserver - WHERE last_contact > last_failure AND platform LIKE "%s" + WHERE last_contact > last_failure AND platform LIKE "%s" AND `version` != "" GROUP BY version ORDER BY version;', $p); @@ -344,6 +344,9 @@ function admin_page_federation(&$a) { $v = $newVv; } + foreach ($v as $key => $vv) + $v[$key]["version"] = trim(strip_tags($vv["version"])); + // the 3rd array item is needed for the JavaScript graphs as JS does // not like some characters in the names of variables... $counts[$p]=array($c[0], $v, str_replace(array(' ','%'),'',$p), $colors[$p]); From 411566f48b58135e6820b6557794806b077e5444 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 1 Mar 2016 19:17:01 +0100 Subject: [PATCH 7/7] API: Some small speed improvement when calling the home timeline. --- include/api.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/api.php b/include/api.php index 55e39e358..699b066d2 100644 --- a/include/api.php +++ b/include/api.php @@ -1691,13 +1691,13 @@ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` + FROM `item` FORCE INDEX (`uid_id`), `contact` WHERE `item`.`uid` = %d AND `verb` = '%s' AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s')) - AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 + AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `contact`.`id` = `item`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`) + AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = %d AND `mention` AND !`ignored`) $sql_extra AND `item`.`id`>%d ORDER BY `item`.`id` DESC LIMIT %d ,%d ",