diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index 93319bf..2837cc1 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -84,7 +84,7 @@ function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) { $form['url'] = array('#type' => 'textfield', '#title' => t('URL'), '#default_value' => isset($feed->url) ? $feed->url : '', - '#maxlength' => 255, + '#maxlength' => NULL, '#description' => t('The fully-qualified URL of the feed.'), '#required' => TRUE, ); diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index eecd14f..ac4fce8 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -130,10 +130,8 @@ function aggregator_schema() { 'description' => 'Title of the feed.', ), 'url' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => TRUE, - 'default' => '', 'description' => 'URL to the feed.', ), 'refresh' => array( @@ -155,10 +153,8 @@ function aggregator_schema() { 'description' => 'Time when this feed was queued for refresh, 0 if not queued.', ), 'link' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => TRUE, - 'default' => '', 'description' => 'The parent website of the feed; comes from the element in the feed.', ), 'description' => array( @@ -202,13 +198,13 @@ function aggregator_schema() { ) ), 'primary key' => array('fid'), - 'unique keys' => array( - 'url' => array('url'), - 'title' => array('title'), - ), 'indexes' => array( + 'url' => array(array('url', 255)), 'queued' => array('queued'), ), + 'unique keys' => array( + 'title' => array('title'), + ), ); $schema['aggregator_item'] = array( @@ -233,10 +229,8 @@ function aggregator_schema() { 'description' => 'Title of the feed item.', ), 'link' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => TRUE, - 'default' => '', 'description' => 'Link to the feed item.', ), 'author' => array( @@ -258,9 +252,8 @@ function aggregator_schema() { 'description' => 'Posted date of the feed item, as a Unix timestamp.', ), 'guid' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, + 'type' => 'text', + 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.', ) ), diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index bb66cbe..81b8c7f 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -537,6 +537,7 @@ function aggregator_save_feed($edit) { 'url' => $edit['url'], 'refresh' => $edit['refresh'], 'block' => $edit['block'], + 'link' => '', 'description' => '', 'image' => '', )) @@ -573,15 +574,13 @@ function aggregator_remove($feed) { // Call hook_aggregator_remove() on all modules. module_invoke_all('aggregator_remove', $feed); // Reset feed. - db_merge('aggregator_feed') - ->key(array('fid' => $feed->fid)) + db_update('aggregator_feed') + ->condition('fid', $feed->fid) ->fields(array( 'checked' => 0, 'hash' => '', 'etag' => '', 'modified' => 0, - 'description' => $feed->description, - 'image' => $feed->image, )) ->execute(); } diff --git a/core/modules/aggregator/aggregator.parser.inc b/core/modules/aggregator/aggregator.parser.inc index 0f594d4..2c5dbab 100644 --- a/core/modules/aggregator/aggregator.parser.inc +++ b/core/modules/aggregator/aggregator.parser.inc @@ -111,7 +111,7 @@ function aggregator_parse_feed(&$data, $feed) { $item['title'] = ''; } - // Resolve the items link. + // Resolve the item's link. if (!empty($item['link'])) { $item['link'] = $item['link']; } diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test index 27c4673..9a51106 100644 --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -349,6 +349,37 @@ class AddFeedTestCase extends AggregatorTestCase { // Delete feed. $this->deleteFeed($feed); } + + /** + * Tests for feeds with very long URLs. + */ + function testAddLongFeed() { + // Create a feed with a URL of > 255 characters. + $long_url = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889&ix=heb"; + $feed = $this->createFeed($long_url); + + // Create a second feed of > 255 characters, where the only difference is + // after the 255th character. + $long_url_2 = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889"; + $feed_2 = $this->createFeed($long_url_2); + + // Check feed data. + $this->assertTrue($this->uniqueFeed($feed->title, $feed->url), t('The first long URL feed is unique.')); + $this->assertTrue($this->uniqueFeed($feed_2->title, $feed_2->url), t('The second long URL feed is unique.')); + + + // Check feed source. + $this->drupalGet('aggregator/sources/' . $feed->fid); + $this->assertResponse(200, t('Long URL feed source exists.')); + $this->assertText($feed->title, t('Page title')); + $this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize'); + $this->assertResponse(200, t('Long URL feed categorization page exists.')); + + // Delete feeds. + $this->deleteFeed($feed); + $this->deleteFeed($feed_2); + + } } class CategorizeFeedTestCase extends AggregatorTestCase {