This occurs in the aggregator2 modules when doing a refresh in common.inc:265 - header('Location: '. $url); I believe the problem is due to having a $base_url set but it is not processed correctly in bootstrap.inc:148. The strlen($parts['path']) never checked to make sure $parts['path'] is set. The fix is quite simple:

 $base_root = substr($base_url, 0, strlen($base_url) - (isset($parts['path']) ? strlen($parts['path']) : 0));
CommentFileSizeAuthor
#2 agg2flush.patch.txt690 bytesadixon
bootstrap_18.patch569 bytesrw712

Comments

adixon’s picture

Project: Drupal core » Aggregator2
Version: 4.7.0-rc3 » master
Component: base system » Code

this fix is already in bootstrap.inc as:

    $parts = parse_url($base_url);
    if (!isset($parts['path'])) {
      $parts['path'] = '';
    }
    $base_path = $parts['path'] . '/';

on the other hand, aggregator2 is still crapping out on a refresh sometimes, I suspect it's in the aggregator2 code somewhere (perhaps getting the feed information via http outputs a header somehow?).

Conclusion - i'm changing this to an aggregator2 module bug.

adixon’s picture

Status: Active » Needs review
StatusFileSize
new690 bytes

Okay, turns out the refresh bug is in fact in aggregator2, i've attached a patch that fixes it.

Commentary:

It's not so critical because normally the refresh is handled by the cron, and the refresh is actually working, it just fails at the end with the drupal_goto() call. The problem is in the calls to flush() immediately before various sleep commands included in the feed parsing. I don't know why those flush commands are there, but they are generating headers that show up when I check with a header_sent (they seem to be empty headers). I tried putting ob_start() and ob_end_clean() around the flushes but that didn't work (because it was outputing headers, not content), but then i converted the flushes to ob_clean() and that solved it. I suspecting those flushes were there in error (you use the flush() trick if you're trying to use sleep as a way of animating output, i'm guessing they just got put in by copying from some sleep() function example).

johnhanley’s picture

adixon,

Thanks for researching and resolving this issue. It has been hounding me for awhile.

My previous attempts in diagnosing the problem revealed that ob_get_length() was zero immediately before executing

drupal_goto('admin/aggregator2');

at the end of content_import_admin_refresh_feed(), yet the "headers already sent" message persisted.

I am beginning to suspect that this is a PHP 5 issue because I don't remember this occurring with PHP 4.x.

In any event thanks again.

jimmychuang’s picture

Could you attach the correct files let me to replace the error one?

I have no idea about coding.

dimitryous’s picture

Title: Fix for headers already sent » Headers already sent
Version: master » 4.6.x-1.x-dev
Priority: Normal » Critical

warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/drupal-4.6.9/includes/database.mysql.inc:27) in /Library/WebServer/Documents/drupal-4.6.9/includes/common.inc on line 99.

MacOS 10.3.9
php 4.3.11
MySQL - 4.1.20-max
Apache 1.3.33
drupal-4.6.9

Cannot login after first user created:
warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/drupal-4.6.9/includes/database.mysql.inc:27) in /Library/WebServer/Documents/drupal-4.6.9/includes/common.inc on line 99.
warning: session_regenerate_id() [function.session-regenerate-id.html]: Cannot send session cookie - headers already sent by (output started at /Library/WebServer/Documents/drupal-4.6.9/includes/database.mysql.inc:27) in /Library/WebServer/Documents/drupal-4.6.9/modules/user.module on line 817.
warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/drupal-4.6.9/includes/database.mysql.inc:27) in /Library/WebServer/Documents/drupal-4.6.9/includes/common.inc on line 192.

Blank page ...

Do I have a chance to get all the stuff working ok if I UPGRADE?