Skip to content

Commit 5e0b959

Browse files
author
Peter
committed
Merge pull request pressflow#10 from pdrakeweb/module_implements
[#27386523] Merge feature branch with pressflow-6.25.108.
2 parents c133d6d + 6847e40 commit 5e0b959

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+679
-279
lines changed

CHANGELOG.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11

2+
Drupal 6.25, 2012-02-29
3+
----------------------
4+
- Fixed regressions introduced in Drupal 6.24 only.
5+
6+
Drupal 6.24, 2012-02-01
7+
----------------------
8+
- Improved performance of search indexing and user operations by adding indexes.
9+
- Fixed issues with themes getting disabled due to missing locking in
10+
system_theme_data().
11+
- Fix issue with blocks being disabled on updates in _block_rehash().
12+
- Further improvements to PHP 5.3, PHP 4 and PostgreSQL compatibility.
13+
- Improved code documentation at various places.
14+
- Fixed a variety of other bugs.
15+
216
Drupal 6.23, 2012-02-01
317
----------------------
418
- Fixed security issues (Cross site scripting), see SA-CORE-2012-001.

INSTALL.mysql.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ initial database files. Next you must login and set the access database rights:
2020
Again, you will be asked for the 'username' database password. At the MySQL
2121
prompt, enter following command:
2222

23-
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER
24-
ON databasename.*
23+
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
24+
CREATE TEMPORARY TABLES ON databasename.*
2525
TO 'username'@'localhost' IDENTIFIED BY 'password';
2626

2727
where

includes/actions.inc

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@
2424
* @} End of "defgroup actions".
2525
*/
2626

27-
/**
28-
* @defgroup actions Actions
29-
* @{
30-
* Functions that perform an action on a certain system object.
31-
*
32-
* All modules should declare their action functions to be in this group and
33-
* each action function should reference its configuration form, validate, and
34-
* submit functions using \@see. Conversely, form, validate, and submit
35-
* functions should reference the action function using \@see. For examples of
36-
* this see comment_unpublish_by_keyword_action(), which has the following in
37-
* its doxygen documentation:
38-
*
39-
* \@ingroup actions
40-
* \@see comment_unpublish_by_keyword_action_form().
41-
* \@see comment_unpublish_by_keyword_action_submit().
42-
*
43-
* @} End of "defgroup actions".
44-
*/
45-
4627
/**
4728
* Perform a given list of actions by executing their callback functions.
4829
*
@@ -355,7 +336,7 @@ function actions_synchronize($actions_in_code = array(), $delete_orphans = FALSE
355336
else {
356337
$link = l(t('Remove orphaned actions'), 'admin/settings/actions/orphan');
357338
$count = count($actions_in_db);
358-
watchdog('actions', format_plural($count, 'One orphaned action (%orphans) exists in the actions table. !link', '@count orphaned actions (%orphans) exist in the actions table. !link'), array('@count' => $count, '%orphans' => $orphans, '!link' => $link), WATCHDOG_WARNING);
339+
watchdog('actions', format_plural($count, 'One orphaned action (%orphans) exists in the actions table. !link', '@count orphaned actions (%orphans) exist in the actions table. !link'), array('@count' => $count, '%orphans' => $orphans, '!link' => $link), WATCHDOG_INFO);
359340
}
360341
}
361342
}

includes/batch.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function _batch_process() {
189189
call_user_func_array($function, array_merge($args, array(&$batch_context)));
190190
}
191191

192-
if ($finished == 1) {
192+
if ($finished >= 1) {
193193
// Make sure this step isn't counted double when computing $current.
194194
$finished = 0;
195195
// Remove the operation and clear the sandbox.

includes/bootstrap.inc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,18 @@ function conf_init() {
386386
global $db_url, $db_slave_url, $db_prefix, $db_collation, $cookie_domain, $conf, $installed_profile, $update_free_access;
387387
$conf = array();
388388

389+
if (!isset($_SERVER['SERVER_PROTOCOL']) || ($_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.0' && $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1')) {
390+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
391+
}
392+
389393
if (isset($_SERVER['HTTP_HOST'])) {
390394
// As HTTP_HOST is user input, ensure it only contains characters allowed
391395
// in hostnames. See RFC 952 (and RFC 2181).
392396
// $_SERVER['HTTP_HOST'] is lowercased here per specifications.
393397
$_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
394398
if (!drupal_valid_http_host($_SERVER['HTTP_HOST'])) {
395399
// HTTP_HOST is invalid, e.g. if containing slashes it may be an attack.
396-
header('HTTP/1.1 400 Bad Request');
400+
header($_SERVER['SERVER_PROTOCOL'] .' 400 Bad Request');
397401
exit;
398402
}
399403
}
@@ -1356,8 +1360,16 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
13561360
* TRUE if access is denied, FALSE if access is allowed.
13571361
*/
13581362
function drupal_is_denied($type, $mask) {
1359-
// Because this function is called for every page request, both cached
1360-
// and non-cached pages, we tried to optimize it as much as possible.
1363+
if ($type == 'host') {
1364+
// Because this function is called with $type == 'host' on every page
1365+
// request, we first check for an array of IP addresses in settings.php
1366+
// before querying the database. In the former case there is no wildcard
1367+
// support.
1368+
$blocked_ips = variable_get('blocked_ips', NULL);
1369+
if (isset($blocked_ips) && is_array($blocked_ips)) {
1370+
return in_array($mask, $blocked_ips);
1371+
}
1372+
}
13611373
// We deny access if the only matching records in the {access} table have
13621374
// status 0 (deny). If any have status 1 (allow), or if there are no
13631375
// matching records, we allow access.
@@ -1480,7 +1492,7 @@ function _drupal_bootstrap($phase) {
14801492
case DRUPAL_BOOTSTRAP_ACCESS:
14811493
// Deny access to hosts which were banned - t() is not yet available.
14821494
if (drupal_is_denied('host', ip_address())) {
1483-
header('HTTP/1.1 403 Forbidden');
1495+
header($_SERVER['SERVER_PROTOCOL'] .' 403 Forbidden');
14841496
print 'Sorry, '. check_plain(ip_address()) .' has been banned.';
14851497
exit();
14861498
}

includes/common.inc

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ if (!defined('E_DEPRECATED')) {
3030
define('E_DEPRECATED', 8192);
3131
}
3232

33+
/**
34+
* Error code indicating that the request made by drupal_http_request() exceeded
35+
* the specified timeout.
36+
*/
37+
define('HTTP_REQUEST_TIMEOUT', -1);
38+
3339
/**
3440
* Set content for a specified region.
3541
*
@@ -347,7 +353,7 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response
347353
*/
348354
function drupal_site_offline() {
349355
drupal_maintenance_theme();
350-
drupal_set_header('HTTP/1.1 503 Service unavailable');
356+
drupal_set_header($_SERVER['SERVER_PROTOCOL'] .' 503 Service unavailable');
351357
drupal_set_title(t('Site off-line'));
352358
print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
353359
t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Pressflow'))))));
@@ -357,7 +363,7 @@ function drupal_site_offline() {
357363
* Generates a 404 error if the request can not be handled.
358364
*/
359365
function drupal_not_found() {
360-
drupal_set_header('HTTP/1.1 404 Not Found');
366+
drupal_set_header($_SERVER['SERVER_PROTOCOL'] .' 404 Not Found');
361367

362368
watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
363369

@@ -387,7 +393,7 @@ function drupal_not_found() {
387393
* Generates a 403 error if the request is not allowed.
388394
*/
389395
function drupal_access_denied() {
390-
drupal_set_header('HTTP/1.1 403 Forbidden');
396+
drupal_set_header($_SERVER['SERVER_PROTOCOL'] .' 403 Forbidden');
391397

392398
watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
393399

@@ -428,11 +434,15 @@ function drupal_access_denied() {
428434
* @param $retry
429435
* An integer representing how many times to retry the request in case of a
430436
* redirect.
437+
* @param $timeout
438+
* A float representing the maximum number of seconds the function call may
439+
* take. The default is 30 seconds. If a timeout occurs, the error code is set
440+
* to the HTTP_REQUEST_TIMEOUT constant.
431441
* @return
432442
* An object containing the HTTP request headers, response code, protocol,
433443
* status message, headers, data and redirect status.
434444
*/
435-
function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
445+
function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3, $timeout = 30.0) {
436446
global $db_prefix;
437447

438448
$result = new stdClass();
@@ -452,18 +462,20 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
452462
return $result;
453463
}
454464

465+
timer_start(__FUNCTION__);
466+
455467
switch ($uri['scheme']) {
456468
case 'http':
457469
case 'feed':
458470
$port = isset($uri['port']) ? $uri['port'] : 80;
459471
$host = $uri['host'] . ($port != 80 ? ':'. $port : '');
460-
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
472+
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, $timeout);
461473
break;
462474
case 'https':
463475
// Note: Only works for PHP 4.3 compiled with OpenSSL.
464476
$port = isset($uri['port']) ? $uri['port'] : 443;
465477
$host = $uri['host'] . ($port != 443 ? ':'. $port : '');
466-
$fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
478+
$fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, $timeout);
467479
break;
468480
default:
469481
$result->error = 'invalid schema '. $uri['scheme'];
@@ -537,11 +549,25 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
537549

538550
$result->request = $request;
539551

540-
fwrite($fp, $request);
552+
// Calculate how much time is left of the original timeout value.
553+
$time_left = $timeout - timer_read(__FUNCTION__) / 1000;
554+
if ($time_left > 0) {
555+
stream_set_timeout($fp, floor($time_left), floor(1000000 * fmod($time_left, 1)));
556+
fwrite($fp, $request);
557+
}
541558

542559
// Fetch response.
543560
$response = '';
544-
while (!feof($fp) && $chunk = fread($fp, 1024)) {
561+
while (!feof($fp)) {
562+
// Calculate how much time is left of the original timeout value.
563+
$time_left = $timeout - timer_read(__FUNCTION__) / 1000;
564+
if ($time_left <= 0) {
565+
$result->code = HTTP_REQUEST_TIMEOUT;
566+
$result->error = 'request timed out';
567+
return $result;
568+
}
569+
stream_set_timeout($fp, floor($time_left), floor(1000000 * fmod($time_left, 1)));
570+
$chunk = fread($fp, 1024);
545571
$response .= $chunk;
546572
}
547573
fclose($fp);
@@ -590,9 +616,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
590616
case 302: // Moved temporarily
591617
case 307: // Moved temporarily
592618
$location = $result->headers['Location'];
593-
594-
if ($retry) {
595-
$result = drupal_http_request($result->headers['Location'], $headers, $method, $data, --$retry);
619+
$timeout -= timer_read(__FUNCTION__) / 1000;
620+
if ($timeout <= 0) {
621+
$result->code = HTTP_REQUEST_TIMEOUT;
622+
$result->error = 'request timed out';
623+
}
624+
elseif ($retry) {
625+
$result = drupal_http_request($result->headers['Location'], $headers, $method, $data, --$retry, $timeout);
596626
$result->redirect_code = $result->code;
597627
}
598628
$result->redirect_url = $location;
@@ -623,7 +653,7 @@ function drupal_error_handler($errno, $message, $filename, $line, $context) {
623653
return;
624654
}
625655

626-
if ($errno & (E_ALL ^ E_DEPRECATED ^ E_NOTICE)) {
656+
if ($errno & (E_ALL ^ E_DEPRECATED)) {
627657
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning', 4096 => 'recoverable fatal error');
628658

629659
// For database errors, we want the line number/file name of the place that
@@ -645,7 +675,9 @@ function drupal_error_handler($errno, $message, $filename, $line, $context) {
645675
}
646676
}
647677

648-
$entry = check_plain($types[$errno]) .': '. filter_xss($message) .' in '. check_plain($filename) .' on line '. check_plain($line) .'.';
678+
// Try to use filter_xss(). If it's too early in the bootstrap process for
679+
// filter_xss() to be loaded, use check_plain() instead.
680+
$entry = check_plain($types[$errno]) .': '. (function_exists('filter_xss') ? filter_xss($message) : check_plain($message)) .' in '. check_plain($filename) .' on line '. check_plain($line) .'.';
649681

650682
// Force display of error messages in update.php.
651683
if (variable_get('error_level', 1) == 1 || strstr($_SERVER['SCRIPT_NAME'], 'update.php')) {
@@ -1789,8 +1821,11 @@ function drupal_add_link($attributes) {
17891821
*
17901822
* Typical candidates for caching are for example styles for nodes across
17911823
* the site, or used in the theme.
1824+
*
17921825
* @return
17931826
* An array of CSS files.
1827+
*
1828+
* @see drupal_get_css()
17941829
*/
17951830
function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
17961831
static $css = array();
@@ -1836,8 +1871,11 @@ function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preproc
18361871
* @param $css
18371872
* (optional) An array of CSS files. If no array is provided, the default
18381873
* stylesheets array is used instead.
1874+
*
18391875
* @return
18401876
* A string of XHTML CSS tags.
1877+
*
1878+
* @see drupal_add_css()
18411879
*/
18421880
function drupal_get_css($css = NULL) {
18431881
$output = '';

includes/database.inc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ function db_prefix_tables($sql) {
115115
* code.
116116
*
117117
* @param $name
118-
* The name assigned to the newly active database connection. If omitted, the
118+
* The key in the $db_url global variable from settings.php. If omitted, the
119119
* default connection will be made active.
120120
*
121-
* @return the name of the previously active database or FALSE if non was found.
121+
* @return
122+
* The name of the previously active database, or FALSE if none was found.
122123
*/
123124
function db_set_active($name = 'default') {
124125
global $db_url, $db_slave_url, $db_type, $active_db, $active_slave_db;
@@ -196,7 +197,7 @@ function _db_error_page($error = '') {
196197
global $db_type;
197198
drupal_init_language();
198199
drupal_maintenance_theme();
199-
drupal_set_header('HTTP/1.1 503 Service Unavailable');
200+
drupal_set_header($_SERVER['SERVER_PROTOCOL'] .' 503 Service Unavailable');
200201
drupal_set_title('Site off-line');
201202

202203
$message = '<p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p>';

includes/file.inc

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ function file_create_filename($basename, $directory) {
497497
}
498498
else {
499499
$name = $basename;
500+
$ext = '';
500501
}
501502

502503
$counter = 0;
@@ -720,7 +721,7 @@ function file_validate_extensions($file, $extensions) {
720721

721722
// Bypass validation for uid = 1.
722723
if ($user->uid != 1) {
723-
$regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
724+
$regex = '/\.('. @ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
724725
if (!preg_match($regex, $file->filename)) {
725726
$errors[] = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $extensions));
726727
}
@@ -868,8 +869,13 @@ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
868869
/**
869870
* Set the status of a file.
870871
*
871-
* @param file A Drupal file object
872-
* @param status A status value to set the file to.
872+
* @param $file
873+
* A Drupal file object.
874+
* @param $status
875+
* A status value to set the file to. One of:
876+
* - FILE_STATUS_PERMANENT
877+
* - FILE_STATUS_TEMPORARY
878+
*
873879
* @return FALSE on failure, TRUE on success and $file->status will contain the
874880
* status.
875881
*/
@@ -956,6 +962,7 @@ function file_download() {
956962

957963
/**
958964
* Finds all files that match a given mask in a given directory.
965+
*
959966
* Directories and files beginning with a period are excluded; this
960967
* prevents hidden files and directories (such as SVN working directories)
961968
* from being scanned.
@@ -972,18 +979,19 @@ function file_download() {
972979
* When TRUE, the directory scan will recurse the entire tree
973980
* starting at the provided directory.
974981
* @param $key
975-
* The key to be used for the returned array of files. Possible
976-
* values are "filename", for the path starting with $dir,
977-
* "basename", for the basename of the file, and "name" for the name
978-
* of the file without an extension.
982+
* The key to be used for the returned associative array of files. Possible
983+
* values are "filename", for the path starting with $dir; "basename", for
984+
* the basename of the file; and "name" for the name of the file without the
985+
* extension.
979986
* @param $min_depth
980987
* Minimum depth of directories to return files from.
981988
* @param $depth
982-
* Current depth of recursion. This parameter is only used internally and should not be passed.
989+
* Current depth of recursion. This parameter is only used internally and
990+
* should not be passed in.
983991
*
984992
* @return
985993
* An associative array (keyed on the provided key) of objects with
986-
* "path", "basename", and "name" members corresponding to the
994+
* "filename", "basename", and "name" members corresponding to the
987995
* matching files.
988996
*/
989997
function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $callback = 0, $recurse = TRUE, $key = 'filename', $min_depth = 0, $depth = 0) {
@@ -997,7 +1005,7 @@ function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $ca
9971005
// Give priority to files in this folder by merging them in after any subdirectory files.
9981006
$files = array_merge(file_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1), $files);
9991007
}
1000-
elseif ($depth >= $min_depth && ereg($mask, $file)) {
1008+
elseif ($depth >= $min_depth && @ereg($mask, $file)) {
10011009
// Always use this match over anything already set in $files with the same $$key.
10021010
$filename = "$dir/$file";
10031011
$basename = basename($file);

0 commit comments

Comments
 (0)