drupal.patch 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. Fix Reverse Proxy Support:
  2. http://drupal.org/node/244593
  3. http://drupal.org/files/issues/drupal_80.patch
  4. Index: includes/bootstrap.inc
  5. --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100
  6. +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200
  7. @@ -272,6 +272,7 @@
  8. */
  9. function conf_init() {
  10. global $base_url, $base_path, $base_root;
  11. + global $base_url_local;
  12. // Export the following settings.php variables to the global namespace
  13. global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
  14. @@ -723,9 +724,22 @@
  15. * generate an equivalent using other environment variables.
  16. */
  17. function request_uri() {
  18. + global $base_url;
  19. + global $base_url_local;
  20. if (isset($_SERVER['REQUEST_URI'])) {
  21. $uri = $_SERVER['REQUEST_URI'];
  22. + if (isset($base_url) && isset($base_url_local)) {
  23. + $parts = parse_url($base_url_local);
  24. + if ( strlen($uri) >= strlen($base_url_local)
  25. + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) {
  26. + $uri = $base_url . substr($uri, strlen($base_url_local));
  27. + }
  28. + elseif ( strlen($uri) >= strlen($parts["path"])
  29. + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) {
  30. + $uri = $base_url . substr($uri, strlen($parts["path"]));
  31. + }
  32. + }
  33. }
  34. else {
  35. if (isset($_SERVER['argv'])) {
  36. Index: sites/default/default.settings.php
  37. --- sites/default/default.settings.php.orig 2007-12-20 10:35:10 +0100
  38. +++ sites/default/default.settings.php 2008-04-09 20:47:32 +0200
  39. @@ -126,6 +126,24 @@
  40. # $base_url = 'http://www.example.com'; // NO trailing slash!
  41. /**
  42. + * Local Base URL (optional).
  43. + *
  44. + * If you are running Drupal behind a reverse proxy, $base_url (see above)
  45. + * usually points to the URL of the reverse proxy. Drupal uses this for
  46. + * all sorts of external URLs. In order to correctly calculate sub-URLs
  47. + * below $base_url for embedded HTML forms, Drupal also has to know the
  48. + * URL on the local/origin server under which Drupal is contacted by the
  49. + * reverse proxy. This is what $base_url_local is for.
  50. + *
  51. + * Examples:
  52. + * $base_url_local = 'http://www.example.com:8080/drupal';
  53. + *
  54. + * It is not allowed to have a trailing slash; Drupal will add it
  55. + * for you.
  56. + */
  57. +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash!
  58. +
  59. +/**
  60. * PHP settings:
  61. *
  62. * To see what PHP settings are possible, including whether they can
  63. -----------------------------------------------------------------------------
  64. 1. Support HTTP Proxies (mainly for update checks, RSS fetching, etc)
  65. http://drupal.org/node/7881
  66. http://drupal.org/files/issues/proxy_11.patch
  67. (post-adjusted and improved by RSE)
  68. 2. Fix CSS Cache Building Procedure
  69. http://drupal.org/node/275381
  70. http://drupal.org/files/issues/drupal-css-cache-building.patch
  71. (created by RSE)
  72. Index: includes/common.inc
  73. --- includes/common.inc.orig 2008-04-09 23:11:44 +0200
  74. +++ includes/common.inc 2008-06-26 20:16:16 +0200
  75. @@ -439,13 +439,27 @@
  76. case 'http':
  77. $port = isset($uri['port']) ? $uri['port'] : 80;
  78. $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
  79. - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  80. + if (variable_get('proxy_server', '') != '') {
  81. + $proxy_server = variable_get('proxy_server', '');
  82. + $proxy_port = variable_get('proxy_port', 8080);
  83. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  84. + }
  85. + else {
  86. + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  87. + }
  88. break;
  89. case 'https':
  90. // Note: Only works for PHP 4.3 compiled with OpenSSL.
  91. $port = isset($uri['port']) ? $uri['port'] : 443;
  92. $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
  93. - $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  94. + if (variable_get('proxy_server', '') != '') {
  95. + $proxy_server = variable_get('proxy_server', '');
  96. + $proxy_port = variable_get('proxy_port', 8080);
  97. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  98. + }
  99. + else {
  100. + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  101. + }
  102. break;
  103. default:
  104. $result->error = 'invalid schema '. $uri['scheme'];
  105. @@ -462,9 +476,14 @@
  106. }
  107. // Construct the path to act on.
  108. - $path = isset($uri['path']) ? $uri['path'] : '/';
  109. - if (isset($uri['query'])) {
  110. - $path .= '?'. $uri['query'];
  111. + if (variable_get('proxy_server', '') != '') {
  112. + $path = $url;
  113. + }
  114. + else {
  115. + $path = isset($uri['path']) ? $uri['path'] : '/';
  116. + if (isset($uri['query'])) {
  117. + $path .= '?'. $uri['query'];
  118. + }
  119. }
  120. // Create HTTP request.
  121. @@ -482,6 +501,14 @@
  122. $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  123. }
  124. + // If the proxy server required a username then attempt to authenticate with it
  125. + if (variable_get('proxy_username', '') != '') {
  126. + $username = variable_get('proxy_username', '');
  127. + $password = variable_get('proxy_password', '');
  128. + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
  129. + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
  130. + }
  131. +
  132. foreach ($headers as $header => $value) {
  133. $defaults[$header] = $header .': '. $value;
  134. }
  135. @@ -1805,7 +1832,7 @@
  136. $last = '';
  137. while ($path != $last) {
  138. $last = $path;
  139. - $path = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $path);
  140. + $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
  141. }
  142. return 'url('. $path .')';
  143. }
  144. Index: modules/system/system.admin.inc
  145. --- modules/system/system.admin.inc.orig 2008-03-25 12:58:16 +0100
  146. +++ modules/system/system.admin.inc 2008-04-24 11:43:07 +0200
  147. @@ -1363,6 +1363,65 @@
  148. }
  149. /**
  150. + * Form builder; Configure the site proxy settings.
  151. + *
  152. + * @ingroup forms
  153. + * @see system_settings_form()
  154. + */
  155. +function system_proxy_settings() {
  156. +
  157. + $form['forward_proxy'] = array(
  158. + '#type' => 'fieldset',
  159. + '#title' => t('Forward proxy settings'),
  160. + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'),
  161. + );
  162. + $form['forward_proxy']['proxy_server'] = array(
  163. + '#type' => 'textfield',
  164. + '#title' => t('Proxy host name'),
  165. + '#default_value' => variable_get('proxy_server', ''),
  166. + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.')
  167. + );
  168. + $form['forward_proxy']['proxy_port'] = array(
  169. + '#type' => 'textfield',
  170. + '#title' => t('Proxy port number'),
  171. + '#default_value' => variable_get('proxy_port', 8080),
  172. + '#description' => t('The port number of the proxy server, eg. 8080'),
  173. + );
  174. + $form['forward_proxy']['proxy_username'] = array(
  175. + '#type' => 'textfield',
  176. + '#title' => t('Proxy username'),
  177. + '#default_value' => variable_get('proxy_username', ''),
  178. + '#description' => t('The username used to authenticate with the proxy server.'),
  179. + );
  180. + $form['forward_proxy']['proxy_password'] = array(
  181. + '#type' => 'textfield',
  182. + '#title' => t('Proxy password'),
  183. + '#default_value' => variable_get('proxy_password', ''),
  184. + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '')
  185. + );
  186. + $form['#validate'][] = 'system_proxy_settings_validate';
  187. +
  188. + return system_settings_form($form);
  189. +}
  190. +
  191. +/**
  192. + * Validate the submitted proxy form.
  193. + */
  194. +function system_proxy_settings_validate($form, &$form_state) {
  195. + // Validate the proxy settings
  196. + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']);
  197. + if ($form_state['values']['proxy_server'] != '') {
  198. + // TCP allows the port to be between 0 and 65536 inclusive
  199. + if (!is_numeric($form_state['values']['proxy_port'])) {
  200. + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
  201. + }
  202. + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
  203. + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
  204. + }
  205. + }
  206. +}
  207. +
  208. +/**
  209. * Form builder; Configure the site file handling.
  210. *
  211. * @ingroup forms
  212. Index: modules/system/system.module
  213. --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200
  214. +++ modules/system/system.module 2008-04-24 11:43:47 +0200
  215. @@ -55,7 +55,7 @@
  216. $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>';
  217. $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>';
  218. $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>';
  219. - $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>';
  220. + $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>';
  221. $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>';
  222. return $output;
  223. case 'admin':
  224. @@ -406,6 +406,14 @@
  225. 'access arguments' => array('administer site configuration'),
  226. 'file' => 'system.admin.inc',
  227. );
  228. + $items['admin/settings/proxy'] = array(
  229. + 'title' => 'Proxy server',
  230. + 'description' => 'Configure settings when the site is behind a proxy server.',
  231. + 'page callback' => 'drupal_get_form',
  232. + 'page arguments' => array('system_proxy_settings'),
  233. + 'access arguments' => array('administer site configuration'),
  234. + 'file' => 'system.admin.inc',
  235. + );
  236. $items['admin/settings/file-system'] = array(
  237. 'title' => 'File system',
  238. 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
  239. -----------------------------------------------------------------------------
  240. Properly activate Drupal support module in TinyMCE
  241. Index: sites/all/modules/tinymce/plugin_reg.php
  242. --- sites/all/modules/tinymce/plugin_reg.php.orig 2008-03-27 21:11:17 +0100
  243. +++ sites/all/modules/tinymce/plugin_reg.php 2008-05-02 20:56:56 +0200
  244. @@ -102,5 +102,9 @@
  245. $plugins['zoom'] = array();
  246. $plugins['zoom']['theme_advanced_buttons2'] = array('zoom');
  247. +$plugins['drupalimage'] = array();
  248. +$plugins['drupalimage']['theme_advanced_buttons1'] = array('drupalimage');
  249. +$plugins['drupalimage']['extended_valid_elements'] = array('img[class|src|border=0|alt|title|width|height|align|name]');
  250. +
  251. return $plugins;
  252. }
  253. -----------------------------------------------------------------------------
  254. Optimize "img_assist" module by loading only when necessary.
  255. http://drupal.org/node/55101
  256. Index: sites/all/modules/img_assist/img_assist.js
  257. --- sites/all/modules/img_assist/img_assist.js.orig 2008-04-06 18:43:18 +0200
  258. +++ sites/all/modules/img_assist/img_assist.js 2008-05-02 21:05:56 +0200
  259. @@ -130,6 +130,24 @@
  260. var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  261. }
  262. +function launch_popup(nid, mw, mh) {
  263. + var ox = mw;
  264. + var oy = mh;
  265. + if((ox>=screen.width) || (oy>=screen.height)){
  266. + var ox = screen.width-150;
  267. + var oy = screen.height-150;
  268. + var winx = (screen.width / 2)-(ox / 2);
  269. + var winy = (screen.height / 2)-(oy / 2);
  270. + var use_scrollbars = 1;
  271. + }
  272. + else{
  273. + var winx = (screen.width / 2)-(ox / 2);
  274. + var winy = (screen.height / 2)-(oy / 2);
  275. + var use_scrollbars = 0;
  276. + }
  277. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  278. +}
  279. +
  280. function insertImage() {
  281. if (window.opener) {
  282. // Get variables from the fields on the properties frame
  283. Index: sites/all/modules/img_assist/img_assist.module
  284. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:04:49 +0200
  285. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:07:24 +0200
  286. @@ -126,7 +126,7 @@
  287. }
  288. // Assign base_path to insert in image source by javascript.
  289. drupal_add_js('var BASE_URL = "'. base_path() .'";', 'inline');
  290. - drupal_add_js($path .'/img_assist.js');
  291. + drupal_add_js($path .'/img_assist_popup.js');
  292. }
  293. /**
  294. @@ -150,6 +150,9 @@
  295. * Add image link underneath textareas.
  296. */
  297. function img_assist_textarea($element) {
  298. + $path = drupal_get_path('module', 'img_assist');
  299. + drupal_add_js($path .'/img_assist.js');
  300. +
  301. $link = variable_get('img_assist_link', 'icon');
  302. if (($link == 'icon') || ($link == 'text')) {
  303. if (_img_assist_textarea_match($element['#id']) && _img_assist_page_match() && !strstr($_GET['q'], 'img_assist')) {
  304. Index: sites/all/modules/img_assist/img_assist_popup.js
  305. --- /dev/null 2008-05-02 21:08:21 +0200
  306. +++ sites/all/modules/img_assist/img_assist_popup.js 2008-05-02 21:05:56 +0200
  307. @@ -0,0 +1,20 @@
  308. +/* $Id: drupal.patch,v 1.33 2008/10/15 18:04:40 rse Exp $ */
  309. +
  310. +function launch_popup(nid, mw, mh) {
  311. + var ox = mw;
  312. + var oy = mh;
  313. + if((ox>=screen.width) || (oy>=screen.height)){
  314. + var ox = screen.width-150;
  315. + var oy = screen.height-150;
  316. + var winx = (screen.width / 2)-(ox / 2);
  317. + var winy = (screen.height / 2)-(oy / 2);
  318. + var use_scrollbars = 1;
  319. + }
  320. + else{
  321. + var winx = (screen.width / 2)-(ox / 2);
  322. + var winy = (screen.height / 2)-(oy / 2);
  323. + var use_scrollbars = 0;
  324. + }
  325. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  326. +}
  327. +
  328. -----------------------------------------------------------------------------
  329. Fix file permissions.
  330. http://drupal.org/node/247992
  331. Index: sites/all/modules/img_assist/img_assist.module
  332. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:11:15 +0200
  333. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:11:48 +0200
  334. @@ -1230,6 +1230,8 @@
  335. drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'error');
  336. }
  337. else {
  338. + // Set standard file permissions for webserver-generated files
  339. + @chmod(file_create_path($destination), 0664);
  340. $node->images[$key] = $destination;
  341. _image_insert($node, $key, file_create_path($destination));
  342. }
  343. -----------------------------------------------------------------------------
  344. Activate the Drupal glue code for the FCKeditor filemanager.
  345. Index: sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php
  346. --- sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php.orig 2008-03-25 16:28:24 +0100
  347. +++ sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php 2008-05-02 23:02:23 +0200
  348. @@ -39,6 +39,9 @@
  349. // Attention: The above 'UserFilesPath' must point to the same directory.
  350. $Config['UserFilesAbsolutePath'] = '' ;
  351. +// activate Drupal glue code for filemanager
  352. +require_once "../../../../../filemanager.config.php";
  353. +
  354. // Due to security issues with Apache modules, it is recommended to leave the
  355. // following setting enabled.
  356. $Config['ForceSingleExtension'] = true ;
  357. -----------------------------------------------------------------------------
  358. Disable "Update notifications" check by default during installation.
  359. Index: install.php
  360. --- install.php.orig 2008-02-08 23:00:45 +0100
  361. +++ install.php 2008-05-09 13:18:09 +0200
  362. @@ -1069,7 +1069,7 @@
  363. '#type' => 'checkboxes',
  364. '#title' => st('Update notifications'),
  365. '#options' => array(1 => st('Check for updates automatically')),
  366. - '#default_value' => array(1),
  367. + '#default_value' => array(),
  368. '#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')),
  369. '#weight' => 15,
  370. );
  371. -----------------------------------------------------------------------------
  372. No need to always expand the "Menu settings" on node edit pages.
  373. Index: modules/menu/menu.module
  374. --- modules/menu/menu.module.orig 2008-04-09 23:11:48 +0200
  375. +++ modules/menu/menu.module 2008-05-16 20:03:48 +0200
  376. @@ -366,7 +366,7 @@
  377. '#title' => t('Menu settings'),
  378. '#access' => user_access('administer menu'),
  379. '#collapsible' => TRUE,
  380. - '#collapsed' => FALSE,
  381. + '#collapsed' => TRUE,
  382. '#tree' => TRUE,
  383. '#weight' => -2,
  384. '#attributes' => array('class' => 'menu-item-form'),
  385. -----------------------------------------------------------------------------
  386. Use a larger text-area on node edit pages.
  387. Index: modules/node/node.pages.inc
  388. --- modules/node/node.pages.inc.orig 2008-02-27 20:44:44 +0100
  389. +++ modules/node/node.pages.inc 2008-05-16 20:06:45 +0200
  390. @@ -287,7 +287,8 @@
  391. '#type' => 'textarea',
  392. '#title' => check_plain($label),
  393. '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
  394. - '#rows' => 20,
  395. + '#rows' => 30,
  396. + '#cols' => 80,
  397. '#required' => ($word_count > 0),
  398. );
  399. -----------------------------------------------------------------------------
  400. 1. Fix content validation in "xmlcontent" module in case
  401. one has enabled multiple filters on a particular input format.
  402. 2. Additionally, allow absolute paths to support .xsd/.xsl files
  403. in arbitrary directories.
  404. 3. Finally, do not create a new DOM and output it as XML. Instead directly
  405. output the transformed XML in order to get rid of the <?xml...?> declaration.
  406. 4. Additionally, support an optional XML content template (mainly
  407. for loading ENTITY definitions which cannot be done via XSD and XSLT)
  408. Index: sites/all/modules/xmlcontent/xmlcontent.module
  409. --- sites/all/modules/xmlcontent/xmlcontent.module.orig 2007-03-14 22:59:59 +0100
  410. +++ sites/all/modules/xmlcontent/xmlcontent.module 2008-05-30 21:13:16 +0200
  411. @@ -39,8 +39,22 @@
  412. return t('Allows users to post XML node content and get it transformed through a configured XSLT script');
  413. case 'process':
  414. - $xslt_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_xslt_path_$format", '');
  415. - return _xmlcontent_transform($text, $xslt_path);
  416. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  417. + if ($tpl_path) {
  418. + if (substr($tpl_path, 0, 1) != "/")
  419. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  420. + $tpl = file_get_contents($tpl_path);
  421. + $text = preg_replace("/&template_body;/", $text, $tpl);
  422. + $cwd = getcwd();
  423. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  424. + }
  425. + $xslt_path = variable_get("xmlcontent_xslt_path_$format", '');
  426. + if (substr($xslt_path, 0, 1) != "/")
  427. + $xslt_path = drupal_get_path('module', 'xmlcontent') . '/' . $xslt_path;
  428. + $result = _xmlcontent_transform($text, $xslt_path);
  429. + if ($tpl_path)
  430. + chdir($cwd);
  431. + return $result;
  432. case 'settings':
  433. return _xmlcontent_filter_settings($format);
  434. @@ -72,7 +86,7 @@
  435. }
  436. // Does the input format of this node use XML Content filter?
  437. $format = filter_resolve_format($node->format);
  438. - $module = db_result(db_query('SELECT module FROM {filters} WHERE format = %d', $format));
  439. + $module = db_result(db_query("SELECT module FROM {filters} WHERE format = %d AND module = 'xmlcontent'", $format));
  440. if ($module != 'xmlcontent') {
  441. return;
  442. }
  443. @@ -83,7 +97,10 @@
  444. return;
  445. }
  446. - $schema_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_schema_path_$format",'');
  447. + $schema_path = variable_get("xmlcontent_schema_path_$format", '');
  448. + if (substr($schema_path, 0, 1) != "/")
  449. + $schema_path = drupal_get_path('module', 'xmlcontent') . '/' . $schema_path;
  450. +
  451. if (!is_file($schema_path) && ($validation == 'xsd' or $validation == 'rng')) {
  452. $schema_path = null;
  453. watchdog( 'xmlcontent', t('Validation required but no schema file'), WATCHDOG_WARNING );
  454. @@ -93,7 +110,23 @@
  455. libxml_clear_errors();
  456. libxml_use_internal_errors(true);
  457. - if (!_xmlcontent_validate($node->body, $validation, $schema_path)) {
  458. + $text = $node->body;
  459. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  460. + if ($tpl_path) {
  461. + if (substr($tpl_path, 0, 1) != "/")
  462. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  463. + $tpl = file_get_contents($tpl_path);
  464. + $text = preg_replace("/&template_body;/", $text, $tpl);
  465. + $cwd = getcwd();
  466. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  467. + }
  468. +
  469. + $result = _xmlcontent_validate($text, $validation, $schema_path);
  470. +
  471. + if ($tpl_path)
  472. + chdir($cwd);
  473. +
  474. + if (!$result) {
  475. form_set_error('body', t('XML Content: Invalid XML') . libxml_errors_string());
  476. }
  477. @@ -156,6 +189,13 @@
  478. '#collapsible' => TRUE,
  479. '#collapsed' => FALSE,
  480. );
  481. + $form['xmlcontent']["xmlcontent_tpl_path_$format"] = array(
  482. + '#type' => 'textfield',
  483. + '#title' => t('Optional XML Template File Path'),
  484. + '#default_value' => variable_get("xmlcontent_tpl_path_$format", ''),
  485. + '#field_prefix' => drupal_get_path('module', 'xmlcontent'). '/',
  486. + '#description' => t('The file path to the optional XML template, wrapper around the XML content before processing.'),
  487. + );
  488. $form['xmlcontent']["xmlcontent_xslt_path_$format"] = array(
  489. '#type' => 'textfield',
  490. '#title' => t('XSLT Script File Path'),
  491. @@ -218,6 +258,8 @@
  492. // Load the XML document
  493. $dom = new DomDocument('1.0', 'UTF-8');
  494. + $dom->resolveExternals = true;
  495. + $dom->substituteEntities = true;
  496. $valid = $dom->loadXML($xml);
  497. if (!$valid) {
  498. watchdog('xmlcontent', "Invalid XML Content", WATCHDOG_WARNING);
  499. @@ -227,6 +269,8 @@
  500. // Load the XSLT script
  501. // TODO: is there a way to cache it, or not necessary
  502. $xsl = new DomDocument('1.0', 'UTF-8');
  503. + $xsl->resolveExternals = true;
  504. + $xsl->substituteEntities = true;
  505. $xsl->load($path_to_xslt);
  506. // Create the XSLT processor
  507. @@ -242,10 +286,8 @@
  508. }
  509. // Transform
  510. - $newdom = $proc->transformToDoc($dom);
  511. -
  512. - // Return the output as XML text (in fact subset of XHTML, depending on the XSLT script)
  513. - return $newdom->saveXML();
  514. + $xml = $proc->transformToXML($dom);
  515. + return $xml;
  516. }
  517. -----------------------------------------------------------------------------
  518. Fix upgrading in "simplefeed" module if PostgreSQL is used.
  519. Fix modules as Drupal 6.2 does not provide db_num_rows() anymore.
  520. Index: sites/all/modules/simplefeed/simplefeed.install
  521. --- sites/all/modules/simplefeed/simplefeed.install.orig 2008-06-11 07:22:28 +0200
  522. +++ sites/all/modules/simplefeed/simplefeed.install 2008-06-14 15:09:53 +0200
  523. @@ -31,8 +31,17 @@
  524. function simplefeed_update_2() {
  525. $ret = array();
  526. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  527. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  528. + switch ($GLOBALS['db_type']) {
  529. + case 'mysql':
  530. + case 'mysqli':
  531. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  532. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  533. + break;
  534. + case 'pgsql':
  535. + $ret[] = update_sql("DROP INDEX {simplefeed_feed}_url_idx");
  536. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} ALTER COLUMN url TYPE text");
  537. + break;
  538. + }
  539. return $ret;
  540. }
  541. Index: sites/all/modules/simplefeed/simplefeed_item.install
  542. --- sites/all/modules/simplefeed/simplefeed_item.install.orig 2008-06-11 07:22:28 +0200
  543. +++ sites/all/modules/simplefeed/simplefeed_item.install 2008-06-14 16:23:01 +0200
  544. @@ -40,13 +40,15 @@
  545. // Fetch up to N feed items and update their iids to new schema
  546. $count = $_SESSION['simplefeed_item_update_2']['count'];
  547. $feed_items = db_query_range('SELECT r.vid, r.title, s.url FROM {node_revisions} r JOIN {simplefeed_feed_item} s ON r.vid = s.vid ORDER BY r.vid ASC', $count, $limit);
  548. + $n = 0;
  549. while ($feed_item = db_fetch_object($feed_items)) {
  550. $iid = md5($feed_item->title . $feed_item->url);
  551. db_query("UPDATE {simplefeed_feed_item} SET iid = '%s' WHERE vid = %d", $iid, $feed_item->vid);
  552. $_SESSION['simplefeed_item_update_2']['vid'] = $feed_item->vid;
  553. + $n++;
  554. }
  555. - if (db_num_rows($feed_items) == $limit) {
  556. + if ($n == $limit) {
  557. $_SESSION['simplefeed_item_update_2']['count'] += $limit;
  558. // Return progress (never return 100% here to ensure clean-up is still run last).
  559. return array('#finished' => $_SESSION['simplefeed_item_update_2']['vid'] / ($_SESSION['simplefeed_item_update_2']['max'] + 1));
  560. @@ -60,8 +62,18 @@
  561. function simplefeed_item_update_3() {
  562. $ret = array();
  563. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  564. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  565. + switch ($GLOBALS['db_type']) {
  566. + case 'mysql':
  567. + case 'mysqli':
  568. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  569. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  570. + break;
  571. + case 'pgsql':
  572. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN url TYPE text");
  573. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid TYPE VARCHAR(32)");
  574. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid SET NOT NULL");
  575. + break;
  576. + }
  577. return $ret;
  578. }
  579. Index: sites/all/modules/autologout/autologout.module
  580. --- sites/all/modules/autologout/autologout.module.orig 2008-03-14 21:05:41 +0100
  581. +++ sites/all/modules/autologout/autologout.module 2008-06-14 15:57:27 +0200
  582. @@ -257,8 +257,8 @@
  583. if (_autologout_user_in_by_user_role($account)) {
  584. $account->autologout = 0;
  585. $r = db_query("SELECT setting FROM {autologout} WHERE uid = %d", $account->uid);
  586. - if (db_num_rows($r) > 0) {
  587. - $row = db_fetch_object($r);
  588. + $row = db_fetch_object($r);
  589. + if ($row) {
  590. $account->autologout = (int)$row->setting;
  591. }
  592. }
  593. -----------------------------------------------------------------------------
  594. Fix helpers module for PostgreSQL usage.
  595. Index: sites/all/modules/helpers/helpers_database.module
  596. --- sites/all/modules/helpers/helpers_database.module.orig 2008-04-23 04:38:34 +0200
  597. +++ sites/all/modules/helpers/helpers_database.module 2008-06-16 18:06:41 +0200
  598. @@ -16,7 +16,7 @@
  599. *
  600. * NOTE: This is open code - do not put a function declaration on it.
  601. */
  602. - $db_types = array('mysql', 'mysqli', 'postgres');
  603. + $db_types = array('mysql', 'mysqli', 'pgsql');
  604. $dbtype = $GLOBALS['db_type'];
  605. if (in_array($dbtype, $db_types)) {
  606. // Using include because the site may not be using this so we don't want a fatal error.
  607. Index: sites/all/modules/helpers/includes/dra_pgsql.inc
  608. --- sites/all/modules/helpers/includes/dra_pgsql.inc.orig 2008-06-16 17:49:43 +0200
  609. +++ sites/all/modules/helpers/includes/dra_pgsql.inc 2008-06-16 18:05:19 +0200
  610. @@ -0,0 +1,40 @@
  611. +<?php
  612. +/* $Id */
  613. + /**
  614. + * Return a result array from the previous query. PostgreSql version.
  615. + * This is very handy for building an option list for a form element.
  616. + *
  617. + * @param $result
  618. + * A database query result resource, as returned from db_query().
  619. + * @return
  620. + * The resulting array or FALSE.
  621. + * If the query contains -- the result array would be
  622. + * 0 columns (bool)FALSE
  623. + * 1 column value => value
  624. + * 2 columns 1st value => 2nd value
  625. + * 3 or more 1st value => array(2nd value, 3rd value, ...)
  626. + */
  627. +function db_result_array($result) {
  628. + $array = array();
  629. + while ($row = pg_fetch_array($result, NULL, PGSQL_NUM)) {
  630. + $y = count($row);
  631. + switch ($y) {
  632. + case 0:
  633. + drupal_set_message(t('Db_result_array found no columns in the result set.'), 'error');
  634. + return false;
  635. +
  636. + case 1:
  637. + $array[$row[0]] = $row[0];
  638. + break;
  639. +
  640. + case 2:
  641. + $array[$row[0]] = $row[1];
  642. + break;
  643. +
  644. + default:
  645. + $array[$row[0]] = array_slice($row, 1);
  646. + break;
  647. + }
  648. + }
  649. + return $array;
  650. +}
  651. -----------------------------------------------------------------------------
  652. Fix PostgreSQL usage.
  653. Index: sites/all/modules/nodeupdates/nodeupdates.install
  654. --- sites/all/modules/nodeupdates/nodeupdates.install.orig 2007-12-31 15:11:57 +0100
  655. +++ sites/all/modules/nodeupdates/nodeupdates.install 2008-06-18 18:00:08 +0200
  656. @@ -15,10 +15,10 @@
  657. case 'pgsql':
  658. db_query("CREATE TABLE {nodeupdates} (
  659. - nid integer(10) NOT NULL default '0',
  660. + nid integer NOT NULL default '0',
  661. title varchar(128) NOT NULL default '',
  662. - message longtext NOT NULL default '',
  663. - timestamp integer(11) NOT NULL default '0'
  664. + message text NOT NULL default '',
  665. + timestamp integer NOT NULL default '0'
  666. )");
  667. break;
  668. }
  669. -----------------------------------------------------------------------------
  670. Avoid incorrect ordering of BLOG entries by removing the
  671. db_rewrite_sql() calls which seem to introduce a wrong ordering.
  672. Index: modules/blog/blog.module
  673. --- modules/blog/blog.module.orig 2008-05-19 09:27:35 +0200
  674. +++ modules/blog/blog.module 2008-07-29 21:20:42 +0200
  675. @@ -182,13 +182,13 @@
  676. * Helper function to determine if a user has blog posts already.
  677. */
  678. function _blog_post_exists($account) {
  679. - 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));
  680. + 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));
  681. }
  682. /**
  683. * Implementation of hook_block().
  684. *
  685. - * Displays the most recent 10 blog titles.
  686. + * Displays the most recent 5 blog titles.
  687. */
  688. function blog_block($op = 'list', $delta = 0) {
  689. global $user;
  690. @@ -198,7 +198,7 @@
  691. }
  692. else if ($op == 'view') {
  693. if (user_access('access content')) {
  694. - $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);
  695. + $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);
  696. if ($node_title_list = node_title_list($result)) {
  697. $block['content'] = $node_title_list;
  698. $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
  699. Index: modules/blog/blog.pages.inc
  700. --- modules/blog/blog.pages.inc.orig 2008-02-08 22:15:12 +0100
  701. +++ modules/blog/blog.pages.inc 2008-06-26 17:19:49 +0200
  702. @@ -25,7 +25,7 @@
  703. $output = theme('item_list', $items);
  704. - $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);
  705. + $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);
  706. $has_posts = FALSE;
  707. while ($node = db_fetch_object($result)) {
  708. @@ -64,7 +64,7 @@
  709. $output = theme('item_list', $items);
  710. - $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));
  711. + $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));
  712. $has_posts = FALSE;
  713. while ($node = db_fetch_object($result)) {
  714. @@ -87,7 +87,7 @@
  715. * Menu callback; displays an RSS feed containing recent blog entries of a given user.
  716. */
  717. function blog_feed_user($account) {
  718. - $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));
  719. + $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));
  720. $channel['title'] = $account->name ."'s blog";
  721. $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE));
  722. @@ -102,7 +102,7 @@
  723. * Menu callback; displays an RSS feed containing recent blog entries of all users.
  724. */
  725. function blog_feed_last() {
  726. - $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));
  727. + $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));
  728. $channel['title'] = variable_get('site_name', 'Drupal') .' blogs';
  729. $channel['link'] = url('blog', array('absolute' => TRUE));