Commit 81d8c4ab authored by alexpott's avatar alexpott

Issue #1878302 by martin107, InternetDevels, nick_daffodil, chrisroane: Use...

Issue #1878302 by martin107, InternetDevels, nick_daffodil, chrisroane: Use 'delete' over 'remove' in the aggregator module.
parent 000966e0
......@@ -146,7 +146,7 @@ function aggregator_cron() {
}
}
// Remove queued timestamp after 6 hours assuming the update has failed.
// Delete queued timestamp after 6 hours assuming the update has failed.
db_update('aggregator_feed')
->fields(array('queued' => 0))
->condition('queued', REQUEST_TIME - (3600 * 6), '<')
......
......@@ -15,10 +15,10 @@ aggregator.admin_settings:
_permission: 'administer news feeds'
aggregator.feed_items_delete:
path: '/admin/config/services/aggregator/remove/{aggregator_feed}'
path: '/admin/config/services/aggregator/delete/{aggregator_feed}'
defaults:
_entity_form: 'aggregator_feed.remove_items'
_title: 'Remove items'
_entity_form: 'aggregator_feed.delete_items'
_title: 'Delete items'
requirements:
_permission: 'administer news feeds'
......
......@@ -154,8 +154,8 @@ public function adminOverview() {
'route_name' => 'aggregator.feed_delete',
'route_parameters' => array('aggregator_feed' => $feed->fid),
);
$links['remove'] = array(
'title' => $this->t('Remove items'),
$links['delete_items'] = array(
'title' => $this->t('Delete items'),
'route_name' => 'aggregator.feed_items_delete',
'route_parameters' => array('aggregator_feed' => $feed->fid),
);
......
......@@ -26,7 +26,7 @@
* "form" = {
* "default" = "Drupal\aggregator\FeedFormController",
* "delete" = "Drupal\aggregator\Form\FeedDeleteForm",
* "remove_items" = "Drupal\aggregator\Form\FeedItemsRemoveForm",
* "delete_items" = "Drupal\aggregator\Form\FeedItemsDeleteForm",
* }
* },
* links = {
......@@ -62,10 +62,10 @@ public function label() {
/**
* {@inheritdoc}
*/
public function removeItems() {
public function deleteItems() {
$manager = \Drupal::service('plugin.manager.aggregator.processor');
foreach ($manager->getDefinitions() as $id => $definition) {
$manager->createInstance($id)->remove($this);
$manager->createInstance($id)->delete($this);
}
// Reset feed.
$this->setLastCheckedTime(0);
......@@ -93,10 +93,10 @@ public static function preCreate(EntityStorageControllerInterface $storage_contr
*/
public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
foreach ($entities as $entity) {
// Notify processors to remove stored items.
// Notify processors to delete stored items.
$manager = \Drupal::service('plugin.manager.aggregator.processor');
foreach ($manager->getDefinitions() as $id => $definition) {
$manager->createInstance($id)->remove($entity);
$manager->createInstance($id)->delete($entity);
}
}
}
......
......@@ -216,11 +216,11 @@ public function getLastModified();
public function setLastModified($modified);
/**
* Removes all items from a feed.
* Deletes all items from a feed.
*
* @return \Drupal\aggregator\FeedInterface
* The class instance that this method is called on.
*/
public function removeItems();
public function deleteItems();
}
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\aggregator\Form\FeedItemsRemoveForm.
* Contains \Drupal\aggregator\Form\FeedItemsDeleteForm.
*/
namespace Drupal\aggregator\Form;
......@@ -12,13 +12,13 @@
/**
* Provides a deletion confirmation form for items that belong to a feed.
*/
class FeedItemsRemoveForm extends ContentEntityConfirmFormBase {
class FeedItemsDeleteForm extends ContentEntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $this->entity->label()));
return $this->t('Are you sure you want to delete all items from the feed %feed?', array('%feed' => $this->entity->label()));
}
/**
......@@ -34,14 +34,14 @@ public function getCancelRoute() {
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Remove items');
return $this->t('Delete items');
}
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state) {
$this->entity->removeItems();
$this->entity->deleteItems();
$form_state['redirect_route']['route_name'] = 'aggregator.admin_overview';
}
......
......@@ -46,14 +46,14 @@ public function process(FeedInterface $feed);
public function postProcess(FeedInterface $feed);
/**
* Removes stored feed data.
* Deletes stored feed data.
*
* Called by aggregator if either a feed is deleted or a user clicks on
* "remove items".
* "delete items".
*
* @param \Drupal\aggregator\FeedInterface $feed
* The $feed object whose items are being removed.
* The $feed object whose items are being deleted.
*/
public function remove(FeedInterface $feed);
public function delete(FeedInterface $feed);
}
......@@ -193,13 +193,13 @@ public function process(FeedInterface $feed) {
/**
* {@inheritdoc}
*/
public function remove(FeedInterface $feed) {
public function delete(FeedInterface $feed) {
$iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchCol();
if ($iids) {
entity_delete_multiple('aggregator_item', $iids);
}
// @todo This should be moved out to caller with a different message maybe.
drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->label())));
drupal_set_message(t('The news items from %site have been deleted.', array('%site' => $feed->label())));
}
/**
......@@ -211,7 +211,7 @@ public function postProcess(FeedInterface $feed) {
$aggregator_clear = $this->configuration['items']['expire'];
if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
// Remove all items that are older than flush item timer.
// Delete all items that are older than flush item timer.
$age = REQUEST_TIME - $aggregator_clear;
$iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
':fid' => $feed->id(),
......
......@@ -28,13 +28,13 @@ public function testCron() {
$feed = $this->createFeed();
$this->cronRun();
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(), 'Expected number of items in database.');
$this->removeFeedItems($feed);
$this->deleteFeedItems($feed);
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(), 'Expected number of items in database.');
$this->cronRun();
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(), 'Expected number of items in database.');
// Test feed locking when queued for update.
$this->removeFeedItems($feed);
$this->deleteFeedItems($feed);
db_update('aggregator_feed')
->condition('fid', $feed->id())
->fields(array(
......
......@@ -184,24 +184,24 @@ function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
* @param \Drupal\aggregator\FeedInterface $feed
* Feed object representing the feed.
*/
function removeFeedItems(FeedInterface $feed) {
$this->drupalPostForm('admin/config/services/aggregator/remove/' . $feed->id(), array(), t('Remove items'));
$this->assertRaw(t('The news items from %title have been removed.', array('%title' => $feed->label())), 'Feed items removed.');
function deleteFeedItems(FeedInterface $feed) {
$this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), array(), t('Delete items'));
$this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())), 'Feed items deleted.');
}
/**
* Adds and removes feed items and ensure that the count is zero.
* Adds and deletes feed items and ensure that the count is zero.
*
* @param \Drupal\aggregator\FeedInterface $feed
* Feed object representing the feed.
* @param int $expected_count
* Expected number of feed items.
*/
function updateAndRemove(FeedInterface $feed, $expected_count) {
function updateAndDelete(FeedInterface $feed, $expected_count) {
$this->updateFeedItems($feed, $expected_count);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
$this->assertTrue($count);
$this->removeFeedItems($feed);
$this->deleteFeedItems($feed);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
$this->assertTrue($count == 0);
}
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\aggregator\Tests\RemoveFeedItemTest.
* Definition of Drupal\aggregator\Tests\DeleteFeedItemTest.
*/
namespace Drupal\aggregator\Tests;
......@@ -10,19 +10,19 @@
/**
* Tests functionality of removing a feed item in the Aggregator module.
*/
class RemoveFeedItemTest extends AggregatorTestBase {
class DeleteFeedItemTest extends AggregatorTestBase {
public static function getInfo() {
return array(
'name' => 'Remove feed item functionality',
'description' => 'Remove feed items from a feed.',
'name' => 'Delete feed item functionality',
'description' => 'Delete feed items from a feed.',
'group' => 'Aggregator'
);
}
/**
* Tests running "remove items" from 'admin/config/services/aggregator' page.
* Tests running "delete items" from 'admin/config/services/aggregator' page.
*/
function testRemoveFeedItem() {
function testDeleteFeedItem() {
// Create a bunch of test feeds.
$feed_urls = array();
// No last-modified, no etag.
......@@ -36,13 +36,13 @@ function testRemoveFeedItem() {
foreach ($feed_urls as $feed_url) {
$feed = $this->createFeed($feed_url);
// Update and remove items two times in a row to make sure that removal
// Update and delete items two times in a row to make sure that removal
// resets all 'modified' information (modified, etag, hash) and allows for
// immediate update. There's 8 items in the feed, but one has an empty
// title and is skipped.
$this->updateAndRemove($feed, 7);
$this->updateAndRemove($feed, 7);
$this->updateAndRemove($feed, 7);
$this->updateAndDelete($feed, 7);
$this->updateAndDelete($feed, 7);
$this->updateAndDelete($feed, 7);
// Delete feed.
$this->deleteFeed($feed);
}
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\aggregator\Tests\RemoveFeedTest.
* Definition of Drupal\aggregator\Tests\DeleteFeedTest.
*/
namespace Drupal\aggregator\Tests;
......@@ -10,7 +10,7 @@
/**
* Tests functionality for removing feeds in the Aggregator module.
*/
class RemoveFeedTest extends AggregatorTestBase {
class DeleteFeedTest extends AggregatorTestBase {
/**
* Modules to enable.
......@@ -21,16 +21,16 @@ class RemoveFeedTest extends AggregatorTestBase {
public static function getInfo() {
return array(
'name' => 'Remove feed functionality',
'description' => 'Remove feed test.',
'name' => 'Delete feed functionality',
'description' => 'Delete feed test.',
'group' => 'Aggregator'
);
}
/**
* Removes a feed and ensures that all of its services are removed.
* Deletes a feed and ensures that all of its services are deleted.
*/
function testRemoveFeed() {
function testDeleteFeed() {
$feed1 = $this->createFeed();
$feed2 = $this->createFeed();
......
......@@ -39,8 +39,8 @@ public function testfetch() {
$this->updateFeedItems($feed);
$this->assertFalse(empty($feed->items));
// Remove items and restore checked property to 0.
$this->removeFeedItems($feed);
// Delete items and restore checked property to 0.
$this->deleteFeedItems($feed);
// Change its name and try again.
$feed->setTitle('Do not fetch');
$feed->save();
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
// Do not remove old aggregator items during these tests, since our sample
// Do not delete old aggregator items during these tests, since our sample
// feeds have hardcoded dates in them (which may be expired when this test
// is run).
$this->container->get('config.factory')->get('aggregator.settings')->set('items.expire', AGGREGATOR_CLEAR_NEVER)->save();
......
......@@ -46,11 +46,11 @@ public function testProcess() {
}
/**
* Test removing functionality.
* Test deleting functionality.
*/
public function testRemove() {
public function testDelete() {
$feed = $this->createFeed();
$this->updateAndRemove($feed, NULL);
$this->updateAndDelete($feed, NULL);
// Make sure the feed title is changed.
$entities = entity_load_multiple_by_properties('aggregator_feed', array('description' => $feed->description->value));
$this->assertTrue(empty($entities));
......
......@@ -29,7 +29,7 @@ function testUpdateFeedItem() {
$feed = $this->createFeed();
if (!empty($feed)) {
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
$this->removeFeedItems($feed);
$this->deleteFeedItems($feed);
}
// Delete feed.
......
......@@ -115,7 +115,7 @@ public function testSettingsForm() {
}
namespace {
// @todo Remove after https://drupal.org/node/1858196 is in.
// @todo Delete after https://drupal.org/node/1858196 is in.
if (!function_exists('drupal_set_message')) {
function drupal_set_message() {}
}
......
......@@ -108,7 +108,7 @@ public function process(FeedInterface $feed) {
/**
* {@inheritdoc}
*/
public function remove(FeedInterface $feed) {
public function delete(FeedInterface $feed) {
// Append a random number, just to change the feed description.
$feed->description->value .= rand(0, 10);
}
......
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