Commit df643e13 authored by catch's avatar catch

Issue #218004 by Dave Reid, heyrocker, pcambra, neclimdul et al: Fixed Allow...

Issue #218004 by Dave Reid, heyrocker, pcambra, neclimdul et al: Fixed Allow aggregator feed URLs longer than 255 characters.
parent 5fbf8661
......@@ -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,
);
......
......@@ -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.',
)
),
......
......@@ -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();
}
......
......@@ -349,6 +349,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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment