Tue, 28 Aug 2012 18:28:45 +0200
Import package vendor original specs for necessary manipulations.
1 Fix Reverse Proxy Support:
2 http://drupal.org/node/244593
3 http://drupal.org/files/issues/drupal_80.patch
5 Index: includes/bootstrap.inc
6 --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100
7 +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200
8 @@ -272,6 +272,7 @@
9 */
10 function conf_init() {
11 global $base_url, $base_path, $base_root;
12 + global $base_url_local;
14 // Export the following settings.php variables to the global namespace
15 global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
16 @@ -723,9 +724,22 @@
17 * generate an equivalent using other environment variables.
18 */
19 function request_uri() {
20 + global $base_url;
21 + global $base_url_local;
23 if (isset($_SERVER['REQUEST_URI'])) {
24 $uri = $_SERVER['REQUEST_URI'];
25 + if (isset($base_url) && isset($base_url_local)) {
26 + $parts = parse_url($base_url_local);
27 + if ( strlen($uri) >= strlen($base_url_local)
28 + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) {
29 + $uri = $base_url . substr($uri, strlen($base_url_local));
30 + }
31 + elseif ( strlen($uri) >= strlen($parts["path"])
32 + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) {
33 + $uri = $base_url . substr($uri, strlen($parts["path"]));
34 + }
35 + }
36 }
37 else {
38 if (isset($_SERVER['argv'])) {
39 @@ -792,6 +806,7 @@
40 }
41 }
42 // Prevent multiple slashes to avoid cross site requests via the FAPI.
43 + if (substr($uri, 0, 1) == "/")
44 $uri = '/'. ltrim($uri, '/');
46 return $uri;
47 Index: sites/default/default.settings.php
48 --- sites/default/default.settings.php.orig 2007-12-20 10:35:10 +0100
49 +++ sites/default/default.settings.php 2008-04-09 20:47:32 +0200
50 @@ -126,6 +126,24 @@
51 # $base_url = 'http://www.example.com'; // NO trailing slash!
53 /**
54 + * Local Base URL (optional).
55 + *
56 + * If you are running Drupal behind a reverse proxy, $base_url (see above)
57 + * usually points to the URL of the reverse proxy. Drupal uses this for
58 + * all sorts of external URLs. In order to correctly calculate sub-URLs
59 + * below $base_url for embedded HTML forms, Drupal also has to know the
60 + * URL on the local/origin server under which Drupal is contacted by the
61 + * reverse proxy. This is what $base_url_local is for.
62 + *
63 + * Examples:
64 + * $base_url_local = 'http://www.example.com:8080/drupal';
65 + *
66 + * It is not allowed to have a trailing slash; Drupal will add it
67 + * for you.
68 + */
69 +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash!
70 +
71 +/**
72 * PHP settings:
73 *
74 * To see what PHP settings are possible, including whether they can
76 -----------------------------------------------------------------------------
78 1. Support HTTP Proxies (mainly for update checks, RSS fetching, etc)
79 http://drupal.org/node/7881
80 http://drupal.org/files/issues/proxy_11.patch
81 (post-adjusted and improved by RSE)
83 2. Fix CSS Cache Building Procedure
84 http://drupal.org/node/275381
85 http://drupal.org/files/issues/drupal-css-cache-building.patch
86 (created by RSE)
88 Index: includes/common.inc
89 --- includes/common.inc.orig 2008-04-09 23:11:44 +0200
90 +++ includes/common.inc 2008-06-26 20:16:16 +0200
91 @@ -439,13 +439,27 @@
92 case 'http':
93 $port = isset($uri['port']) ? $uri['port'] : 80;
94 $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
95 - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
96 + if (variable_get('proxy_server', '') != '') {
97 + $proxy_server = variable_get('proxy_server', '');
98 + $proxy_port = variable_get('proxy_port', 8080);
99 + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
100 + }
101 + else {
102 + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
103 + }
104 break;
105 case 'https':
106 // Note: Only works for PHP 4.3 compiled with OpenSSL.
107 $port = isset($uri['port']) ? $uri['port'] : 443;
108 $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
109 - $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
110 + if (variable_get('proxy_server', '') != '') {
111 + $proxy_server = variable_get('proxy_server', '');
112 + $proxy_port = variable_get('proxy_port', 8080);
113 + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
114 + }
115 + else {
116 + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
117 + }
118 break;
119 default:
120 $result->error = 'invalid schema '. $uri['scheme'];
121 @@ -462,9 +476,14 @@
122 }
124 // Construct the path to act on.
125 - $path = isset($uri['path']) ? $uri['path'] : '/';
126 - if (isset($uri['query'])) {
127 - $path .= '?'. $uri['query'];
128 + if (variable_get('proxy_server', '') != '') {
129 + $path = $url;
130 + }
131 + else {
132 + $path = isset($uri['path']) ? $uri['path'] : '/';
133 + if (isset($uri['query'])) {
134 + $path .= '?'. $uri['query'];
135 + }
136 }
138 // Create HTTP request.
139 @@ -482,6 +501,14 @@
140 $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
141 }
143 + // If the proxy server required a username then attempt to authenticate with it
144 + if (variable_get('proxy_username', '') != '') {
145 + $username = variable_get('proxy_username', '');
146 + $password = variable_get('proxy_password', '');
147 + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
148 + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
149 + }
150 +
151 foreach ($headers as $header => $value) {
152 $defaults[$header] = $header .': '. $value;
153 }
154 Index: modules/system/system.admin.inc
155 --- modules/system/system.admin.inc.orig 2008-03-25 12:58:16 +0100
156 +++ modules/system/system.admin.inc 2008-04-24 11:43:07 +0200
157 @@ -1363,6 +1363,65 @@
158 }
160 /**
161 + * Form builder; Configure the site proxy settings.
162 + *
163 + * @ingroup forms
164 + * @see system_settings_form()
165 + */
166 +function system_proxy_settings() {
167 +
168 + $form['forward_proxy'] = array(
169 + '#type' => 'fieldset',
170 + '#title' => t('Forward proxy settings'),
171 + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'),
172 + );
173 + $form['forward_proxy']['proxy_server'] = array(
174 + '#type' => 'textfield',
175 + '#title' => t('Proxy host name'),
176 + '#default_value' => variable_get('proxy_server', ''),
177 + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.')
178 + );
179 + $form['forward_proxy']['proxy_port'] = array(
180 + '#type' => 'textfield',
181 + '#title' => t('Proxy port number'),
182 + '#default_value' => variable_get('proxy_port', 8080),
183 + '#description' => t('The port number of the proxy server, eg. 8080'),
184 + );
185 + $form['forward_proxy']['proxy_username'] = array(
186 + '#type' => 'textfield',
187 + '#title' => t('Proxy username'),
188 + '#default_value' => variable_get('proxy_username', ''),
189 + '#description' => t('The username used to authenticate with the proxy server.'),
190 + );
191 + $form['forward_proxy']['proxy_password'] = array(
192 + '#type' => 'textfield',
193 + '#title' => t('Proxy password'),
194 + '#default_value' => variable_get('proxy_password', ''),
195 + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '')
196 + );
197 + $form['#validate'][] = 'system_proxy_settings_validate';
198 +
199 + return system_settings_form($form);
200 +}
201 +
202 +/**
203 + * Validate the submitted proxy form.
204 + */
205 +function system_proxy_settings_validate($form, &$form_state) {
206 + // Validate the proxy settings
207 + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']);
208 + if ($form_state['values']['proxy_server'] != '') {
209 + // TCP allows the port to be between 0 and 65536 inclusive
210 + if (!is_numeric($form_state['values']['proxy_port'])) {
211 + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
212 + }
213 + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
214 + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
215 + }
216 + }
217 +}
218 +
219 +/**
220 * Form builder; Configure the site file handling.
221 *
222 * @ingroup forms
223 Index: modules/system/system.module
224 --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200
225 +++ modules/system/system.module 2008-04-24 11:43:47 +0200
226 @@ -55,7 +55,7 @@
227 $output .= '<li>'. t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/build/themes'), '@drupal-themes' => 'http://drupal.org/project/themes')) .'</li>';
228 $output .= '<li>'. t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/settings/performance'))) .'</li>';
229 $output .= '<li>'. t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, ping module and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) .'</li>';
230 - $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
231 + $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@proxy-server">proxy server settings</a>, a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
232 $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
233 return $output;
234 case 'admin':
235 @@ -406,6 +406,14 @@
236 'access arguments' => array('administer site configuration'),
237 'file' => 'system.admin.inc',
238 );
239 + $items['admin/settings/proxy'] = array(
240 + 'title' => 'Proxy server',
241 + 'description' => 'Configure settings when the site is behind a proxy server.',
242 + 'page callback' => 'drupal_get_form',
243 + 'page arguments' => array('system_proxy_settings'),
244 + 'access arguments' => array('administer site configuration'),
245 + 'file' => 'system.admin.inc',
246 + );
247 $items['admin/settings/file-system'] = array(
248 'title' => 'File system',
249 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
251 -----------------------------------------------------------------------------
253 Disable "Update notifications" check by default during installation.
255 Index: install.php
256 --- install.php.orig 2008-02-08 23:00:45 +0100
257 +++ install.php 2008-05-09 13:18:09 +0200
258 @@ -1069,7 +1069,7 @@
259 '#type' => 'checkboxes',
260 '#title' => st('Update notifications'),
261 '#options' => array(1 => st('Check for updates automatically')),
262 - '#default_value' => array(1),
263 + '#default_value' => array(),
264 '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')),
265 '#weight' => 15,
266 );
268 -----------------------------------------------------------------------------
270 No need to always expand the "Menu settings" on node edit pages.
272 Index: modules/menu/menu.module
273 --- modules/menu/menu.module.orig 2008-04-09 23:11:48 +0200
274 +++ modules/menu/menu.module 2008-05-16 20:03:48 +0200
275 @@ -366,7 +366,7 @@
276 '#title' => t('Menu settings'),
277 '#access' => user_access('administer menu'),
278 '#collapsible' => TRUE,
279 - '#collapsed' => FALSE,
280 + '#collapsed' => TRUE,
281 '#tree' => TRUE,
282 '#weight' => -2,
283 '#attributes' => array('class' => 'menu-item-form'),
285 -----------------------------------------------------------------------------
287 Use a larger text-area on node edit pages.
289 Index: modules/node/node.pages.inc
290 --- modules/node/node.pages.inc.orig 2008-02-27 20:44:44 +0100
291 +++ modules/node/node.pages.inc 2008-05-16 20:06:45 +0200
292 @@ -287,7 +287,8 @@
293 '#type' => 'textarea',
294 '#title' => check_plain($label),
295 '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
296 - '#rows' => 20,
297 + '#rows' => 30,
298 + '#cols' => 80,
299 '#required' => ($word_count > 0),
300 );
302 -----------------------------------------------------------------------------
304 Avoid incorrect ordering of BLOG entries by removing the
305 db_rewrite_sql() calls which seem to introduce a wrong ordering.
307 Index: modules/blog/blog.module
308 --- modules/blog/blog.module.orig 2008-05-19 09:27:35 +0200
309 +++ modules/blog/blog.module 2008-07-29 21:20:42 +0200
310 @@ -182,13 +182,13 @@
311 * Helper function to determine if a user has blog posts already.
312 */
313 function _blog_post_exists($account) {
314 - return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1));
315 + return (bool)db_result(db_query_range("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1", $account->uid, 0, 1));
316 }
318 /**
319 * Implementation of hook_block().
320 *
321 - * Displays the most recent 10 blog titles.
322 + * Displays the most recent 5 blog titles.
323 */
324 function blog_block($op = 'list', $delta = 0) {
325 global $user;
326 @@ -198,7 +198,7 @@
327 }
328 else if ($op == 'view') {
329 if (user_access('access content')) {
330 - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
331 + $result = db_query_range("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 5);
332 if ($node_title_list = node_title_list($result)) {
333 $block['content'] = $node_title_list;
334 $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
335 Index: modules/blog/blog.pages.inc
336 --- modules/blog/blog.pages.inc.orig 2009-09-14 17:08:00 +0200
337 +++ modules/blog/blog.pages.inc 2009-09-19 08:53:18 +0200
338 @@ -25,7 +25,7 @@
340 $output = theme('item_list', $items);
342 - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
343 + $result = pager_query("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
344 $has_posts = FALSE;
346 while ($node = db_fetch_object($result)) {
347 @@ -64,7 +64,7 @@
349 $output = theme('item_list', $items);
351 - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10));
352 + $result = pager_query("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10));
353 $has_posts = FALSE;
355 while ($node = db_fetch_object($result)) {
356 @@ -87,7 +87,7 @@
357 * Menu callback; displays an RSS feed containing recent blog entries of a given user.
358 */
359 function blog_feed_user($account) {
360 - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
361 + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC", $account->uid, 0, variable_get('feed_default_items', 10));
362 $channel['title'] = t("!name's blog", array('!name' => $account->name));
363 $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE));
365 @@ -102,7 +102,7 @@
366 * Menu callback; displays an RSS feed containing recent blog entries of all users.
367 */
368 function blog_feed_last() {
369 - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
370 + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, variable_get('feed_default_items', 10));
371 $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal')));
372 $channel['link'] = url('blog', array('absolute' => TRUE));