diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-10-09 12:28:33 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-10-09 12:28:33 -0700 |
commit | f6e51414a90ba17a7f24796bc48bf8b95ab16930 (patch) | |
tree | bc85da310a5a86737529974999ef8e9fef1b58ae /modules/aggregator | |
parent | f91d2c95442c3a70aa15ffb31c9d69233e75d9c6 (diff) | |
download | brdo-f6e51414a90ba17a7f24796bc48bf8b95ab16930.tar.gz brdo-f6e51414a90ba17a7f24796bc48bf8b95ab16930.tar.bz2 |
Issue #218004 by Dave Reid, heyrocker, pcambra, neclimdul, alex_b, cam8001, twistor, mfb, catch, xjm, beeradb: Fixed Allow aggregator feed URLs longer than 255 characters.
Diffstat (limited to 'modules/aggregator')
-rw-r--r-- | modules/aggregator/aggregator.admin.inc | 2 | ||||
-rw-r--r-- | modules/aggregator/aggregator.install | 54 | ||||
-rw-r--r-- | modules/aggregator/aggregator.module | 7 | ||||
-rw-r--r-- | modules/aggregator/aggregator.test | 29 |
4 files changed, 71 insertions, 21 deletions
diff --git a/modules/aggregator/aggregator.admin.inc b/modules/aggregator/aggregator.admin.inc index 9f92a6705..8b817c0fa 100644 --- a/modules/aggregator/aggregator.admin.inc +++ b/modules/aggregator/aggregator.admin.inc @@ -77,7 +77,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/modules/aggregator/aggregator.install b/modules/aggregator/aggregator.install index f19d7de9b..b84556a9d 100644 --- a/modules/aggregator/aggregator.install +++ b/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 <link> 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.', ) ), @@ -280,6 +273,11 @@ function aggregator_schema() { } /** + * @addtogroup updates-6.x-to-7.x + * @{ + */ + +/** * Add hash column to aggregator_feed table. */ function aggregator_update_7000() { @@ -306,3 +304,27 @@ function aggregator_update_7002() { db_add_index('aggregator_feed', 'queued', array('queued')); } +/** + * @} End of "addtogroup updates-6.x-to-7.x" + */ + +/** + * @addtogroup updates-7.x-extra + * @{ + */ + +/** + * Increase the length of {aggregator_feed}.url. + */ +function aggregator_update_7003() { + db_drop_unique_key('aggregator_feed', 'url'); + db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.')); + db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.')); + db_change_field('aggregator_item', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'Link to the feed item.')); + db_change_field('aggregator_item', 'guid', 'guid', array('type' => 'text', 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.')); + db_add_index('aggregator_feed', 'url', array(array('url', 255))); +} + +/** + * @} End of "addtogroup updates-7.x-extra" + */ diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 686f4248a..93457c68d 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -534,6 +534,7 @@ function aggregator_save_feed($edit) { 'url' => $edit['url'], 'refresh' => $edit['refresh'], 'block' => $edit['block'], + 'link' => '', 'description' => '', 'image' => '', )) @@ -568,15 +569,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/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index bd7dd5f82..24205fcca 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -350,6 +350,35 @@ class AddFeedTestCase extends AggregatorTestCase { // Delete feed. $this->deleteFeed($feed); } + + /** + * Tests 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), 'The first long URL feed is unique.'); + $this->assertTrue($this->uniqueFeed($feed_2->title, $feed_2->url), 'The second long URL feed is unique.'); + + // Check feed source. + $this->drupalGet('aggregator/sources/' . $feed->fid); + $this->assertResponse(200, 'Long URL feed source exists.'); + $this->assertText($feed->title, 'Page title'); + $this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize'); + $this->assertResponse(200, 'Long URL feed categorization page exists.'); + + // Delete feeds. + $this->deleteFeed($feed); + $this->deleteFeed($feed_2); + } } class CategorizeFeedTestCase extends AggregatorTestCase { |