From 94b49d8a925e4bc7f10cbcf117ba81b071019b73 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 14 Jul 2013 20:44:00 +0200 Subject: [PATCH 1/4] [ticket/11703] Make jQuery CDN switch more generic. Config variable: load_jquery_cdn -> allow_cdn Template variable: S_JQUERY_FALLBACK -> S_ALLOW_CDN PHPBB3-11703 --- phpBB/adm/style/install_footer.html | 2 +- phpBB/adm/style/overall_footer.html | 2 +- phpBB/adm/style/simple_footer.html | 2 +- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/functions.php | 4 +-- phpBB/includes/functions_acp.php | 4 +-- phpBB/install/schemas/schema_data.sql | 2 +- phpBB/language/en/acp/board.php | 4 +-- .../db/migration/data/v310/allow_cdn.php | 28 +++++++++++++++++++ .../prosilver/template/overall_footer.html | 2 +- .../prosilver/template/simple_footer.html | 2 +- .../subsilver2/template/overall_footer.html | 2 +- .../subsilver2/template/simple_footer.html | 2 +- 13 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v310/allow_cdn.php diff --git a/phpBB/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html index 73c3f5a6b9..f7d62d7c7e 100644 --- a/phpBB/adm/style/install_footer.html +++ b/phpBB/adm/style/install_footer.html @@ -13,7 +13,7 @@ - + diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 9202cec06b..145ad18709 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -35,7 +35,7 @@ - + {$SCRIPTS} diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html index 906a9bebed..a559b25b72 100644 --- a/phpBB/adm/style/simple_footer.html +++ b/phpBB/adm/style/simple_footer.html @@ -17,7 +17,7 @@ - + diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 8f2548166b..40dca53b76 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -344,7 +344,7 @@ class acp_board 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_jquery_cdn' => array('lang' => 'LOAD_JQUERY_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'allow_cdn' => array('lang' => 'ALLOW_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'CUSTOM_PROFILE_FIELDS', 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dd0dcc09b6..4ada12b87a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5451,8 +5451,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], - 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, + 'T_JQUERY_LINK' => ($config['allow_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], + 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'T_THEME_NAME' => rawurlencode($user->style['style_path']), 'T_THEME_LANG_NAME' => $user->data['user_lang'], diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 60c44e90e1..3ca0049a1c 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -175,8 +175,8 @@ function adm_page_footer($copyright_html = true) 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Group'), - 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", - 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, + 'T_JQUERY_LINK' => ($config['allow_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", + 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'VERSION' => $config['version']) ); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 4458dde6a3..4f1cdf5a83 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -17,6 +17,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remot INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bookmarks', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_cdn', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_password_reset', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1'); @@ -176,7 +177,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofi INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_cdn', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index f786374ba6..8ca937a58d 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -354,6 +354,8 @@ $lang = array_merge($lang, array( $lang = array_merge($lang, array( 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', + 'ALLOW_CDN' => 'Allow usage of third party content delivery networks', + 'ALLOW_CDN_EXPLAIN' => 'If this setting is enabled, some files will be served from external third party servers instead of your server. This reduces the network bandwidth required by your server, but may present a privacy issue for some board administrators.', 'CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', 'LIMIT_LOAD' => 'Limit system load', 'LIMIT_LOAD_EXPLAIN' => 'If the system’s 1-minute load average exceeds this value the board will automatically go offline. A value of 1.0 equals ~100% utilisation of one processor. This only functions on UNIX based servers and where this information is accessible. The value here resets itself to 0 if phpBB was unable to get the load limit.', @@ -363,8 +365,6 @@ $lang = array_merge($lang, array( 'LOAD_CPF_PM' => 'Display custom profile fields in private messages', 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', - 'LOAD_JQUERY_CDN' => 'Serve jQuery using Google’s CDN', - 'LOAD_JQUERY_CDN_EXPLAIN' => 'If this setting is enabled, jQuery will be served from Google’s AJAX API CDN instead of the copy included with phpBB on your server. If the CDN fails, phpBB will attempt to fall back to the copy included with phpBB.', 'LOAD_USER_ACTIVITY' => 'Show user’s activity', 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', 'READ_NOTIFICATION_EXPIRE_DAYS' => 'Read Notification Expiration', diff --git a/phpBB/phpbb/db/migration/data/v310/allow_cdn.php b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php new file mode 100644 index 0000000000..2570998643 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php @@ -0,0 +1,28 @@ +config['load_jquery_cdn'])), + array('config.remove', array('load_jquery_cdn')), + ); + } +} diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 15a298053b..e26c94f367 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -57,7 +57,7 @@ - + diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index b6afc2fdba..10edece3cd 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -7,7 +7,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index 348db5d309..dbc9fcd7aa 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -12,7 +12,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html index 48d3d934f8..6a9c3096bc 100644 --- a/phpBB/styles/subsilver2/template/simple_footer.html +++ b/phpBB/styles/subsilver2/template/simple_footer.html @@ -6,7 +6,7 @@ - + From 21eae92c27d22a96f847c01770b18f3d00b5aabd Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 14 Jul 2013 21:11:14 +0200 Subject: [PATCH 2/4] [ticket/11703] Add effectively_installed(). PHPBB3-11703 --- phpBB/phpbb/db/migration/data/v310/allow_cdn.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/phpbb/db/migration/data/v310/allow_cdn.php b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php index 2570998643..0b79ac77f9 100644 --- a/phpBB/phpbb/db/migration/data/v310/allow_cdn.php +++ b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php @@ -11,6 +11,11 @@ namespace phpbb\db\migration\data\v310; class allow_cdn extends phpbb_db_migration { + public function effectively_installed() + { + return isset($this->config['allow_cdn']); + } + static public function depends_on() { return array( From a409d398814489b90c94eeb3bf8b3bbde1df0842 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Oct 2013 23:30:29 +0200 Subject: [PATCH 3/4] [ticket/11703] Also use empty() for T_JQUERY_LINK. PHPBB3-11703 --- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_acp.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4ada12b87a..1e33e6284a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5451,7 +5451,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_JQUERY_LINK' => ($config['allow_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], + 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'T_THEME_NAME' => rawurlencode($user->style['style_path']), diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 3ca0049a1c..c83bc1f7a6 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -175,7 +175,7 @@ function adm_page_footer($copyright_html = true) 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Group'), - 'T_JQUERY_LINK' => ($config['allow_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", + 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'VERSION' => $config['version']) ); From 51cc7155041c95ca47147072c1c04449ad0bcf67 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Oct 2013 23:45:22 +0200 Subject: [PATCH 4/4] [ticket/11703] Extend the correct migration class. PHPBB3-11703 --- phpBB/phpbb/db/migration/data/v310/allow_cdn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v310/allow_cdn.php b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php index 0b79ac77f9..aa471df6e7 100644 --- a/phpBB/phpbb/db/migration/data/v310/allow_cdn.php +++ b/phpBB/phpbb/db/migration/data/v310/allow_cdn.php @@ -9,7 +9,7 @@ namespace phpbb\db\migration\data\v310; -class allow_cdn extends phpbb_db_migration +class allow_cdn extends \phpbb\db\migration\migration { public function effectively_installed() {