Skip to content
Snippets Groups Projects
Commit 90d0e4e0 authored by megachriz's avatar megachriz Committed by Megachriz
Browse files

Issue #2943953 by MegaChriz: Fixed fatal error "No more accounts to revert...

Issue #2943953 by MegaChriz: Fixed fatal error "No more accounts to revert to." when trying to unlock a feed.
parent 83e555e6
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ test_dependencies[] = rules:rules ...@@ -15,6 +15,7 @@ test_dependencies[] = rules:rules
test_dependencies[] = variable:variable test_dependencies[] = variable:variable
files[] = includes/FeedsAccountSwitcher.inc files[] = includes/FeedsAccountSwitcher.inc
files[] = includes/FeedsAccountSwitcherException.inc
files[] = includes/FeedsAccountSwitcherInterface.inc files[] = includes/FeedsAccountSwitcherInterface.inc
files[] = includes/FeedsConfigurable.inc files[] = includes/FeedsConfigurable.inc
files[] = includes/FeedsHTTPCache.inc files[] = includes/FeedsHTTPCache.inc
......
...@@ -78,7 +78,7 @@ class FeedsAccountSwitcher implements FeedsAccountSwitcherInterface { ...@@ -78,7 +78,7 @@ class FeedsAccountSwitcher implements FeedsAccountSwitcherInterface {
$this->activateCurrentUser(); $this->activateCurrentUser();
} }
else { else {
throw new RuntimeException('No more accounts to revert to.'); throw new FeedsAccountSwitcherException('No more accounts to revert to.');
} }
// Restore original session saving status if all account switches are // Restore original session saving status if all account switches are
// reverted. // reverted.
......
<?php
/**
* @file
* Contains FeedsAccountSwitcherException.
*/
/**
* Thrown when there is no account to switch back to.
*/
class FeedsAccountSwitcherException extends RuntimeException {
}
...@@ -31,7 +31,7 @@ interface FeedsAccountSwitcherInterface { ...@@ -31,7 +31,7 @@ interface FeedsAccountSwitcherInterface {
* @return FeedsAccountSwitcherInterface * @return FeedsAccountSwitcherInterface
* $this. * $this.
* *
* @throws RuntimeException * @throws FeedsAccountSwitcherException
* When there are no more account switches to revert. * When there are no more account switches to revert.
*/ */
public function switchBack(); public function switchBack();
......
...@@ -933,7 +933,12 @@ class FeedsSource extends FeedsConfigurable { ...@@ -933,7 +933,12 @@ class FeedsSource extends FeedsConfigurable {
public function unlock() { public function unlock() {
$this->clearStates(); $this->clearStates();
$this->save(); $this->save();
$this->releaseLock(); try {
$this->releaseLock();
}
catch (FeedsAccountSwitcherException $exception) {
// Ignore switch back exceptions.
}
} }
/** /**
......
...@@ -650,6 +650,57 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -650,6 +650,57 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this->assertEqual(0, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_clear'")->fetchField()); $this->assertEqual(0, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_clear'")->fetchField());
} }
/**
* Tests unlocking a feed.
*/
public function testUnlock() {
// Just remove the mappings rather than creating a new importer.
$this->removeMappings('syndication', $this->getCurrentMappings('syndication'));
$this->setPlugin('syndication', 'FeedsFileFetcher');
$this->setPlugin('syndication', 'FeedsCSVParser');
$this->setSettings('syndication', NULL, array(
'content_type' => '',
'process_in_background' => TRUE,
'import_period' => FEEDS_SCHEDULE_NEVER,
));
$this->addMappings('syndication', array(
0 => array(
'source' => 'title',
'target' => 'title',
),
1 => array(
'source' => 'GUID',
'target' => 'guid',
'unique' => TRUE,
),
));
$this->importFile('syndication', $this->absolutePath() . '/tests/feeds/many_nodes_ordered.csv', 'Schedule import');
$this->assertEqual(0, db_query("SELECT COUNT(*) FROM {node}")->fetchField());
// Assert that the import button is disabled.
$this->assertFieldDisabled('op');
// Assert that there is one import task in the queue.
$this->assertEqual(1, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_import'")->fetchField());
// Now unlock the feed.
$this->drupalPost('import/syndication/unlock', array(), 'Unlock');
$this->assertText('Importer unlocked.');
// Assert that the unlock button is now disabled.
$this->drupalGet('import/syndication/unlock');
$this->assertFieldDisabled('op');
$this->assertText('This importer is not locked, therefore it cannot be unlocked.');
// And assert that the import button is no longer disabled.
$this->drupalGet('import/syndication');
$this->assertFieldEnabled('op');
}
/** /**
* Tests skip new items. * Tests skip new items.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment