From f8eac7d1a5486106bbb11404d5060b0feb7baf56 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 5 Mar 2014 20:22:03 -0500 Subject: [PATCH 1/3] Sharing optimization Change the storage and display of sharings to improve the time needed to generate the page. Instead of looking for a default value when displaying the sharing links, they are added during the configuration. --- app/Models/Configuration.php | 15 +++++++++++---- app/Models/Share.php | 3 --- app/views/helpers/view/normal_view.phtml | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 827a1d166..85e891b64 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -193,7 +193,9 @@ class FreshRSS_Configuration { if (!is_array($value)) { continue; } - if (array_key_exists('url', $value)) { + + // Verify URL and add default value when needed + if (array_key_exists('url', $value) && $value['url'] !== null) { $is_url = ( filter_var ($value['url'], FILTER_VALIDATE_URL) || (version_compare(PHP_VERSION, '5.3.3', '<') && @@ -203,10 +205,15 @@ class FreshRSS_Configuration { if (!$is_url) { continue; } - if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) { - $value['name'] = $value['type']; - } + } else { + $value['url'] = null; } + + // Add a default name + if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) { + $value['name'] = $value['type']; + } + $this->data['sharing'][] = $value; } } diff --git a/app/Models/Share.php b/app/Models/Share.php index 887fcef05..b146db722 100644 --- a/app/Models/Share.php +++ b/app/Models/Share.php @@ -3,9 +3,6 @@ class FreshRSS_Share { static public function generateUrl($options, $selected, $link, $title) { - if (!array_key_exists('url', $selected)) { - $selected['url'] = ''; - } $share = $options[$selected['type']]; $matches = array( '~URL~', diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index ff535c60a..9fd06ebae 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -138,7 +138,7 @@ if (!empty($this->entries)) {
  • - +
  • From 1fea1277d6dffd6b71a78c33a53422ce1282de9a Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 7 Mar 2014 21:04:16 -0500 Subject: [PATCH 2/3] Change test --- app/Models/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 85e891b64..3e5cd8bad 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -210,7 +210,7 @@ class FreshRSS_Configuration { } // Add a default name - if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) { + if (empty($value['name'])) { $value['name'] = $value['type']; } From 90c840d8f1977c6e7d5117fff24c7daf6af3c951 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 7 Mar 2014 21:11:46 -0500 Subject: [PATCH 3/3] Add a test to avoid warnings in log --- app/views/configure/sharing.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index b50e6ddc4..ddb404ef5 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -35,7 +35,7 @@