Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
The expire checkox does not work. Below is the piece of code which delivers the id's which need to be expired.
return $this->queryFactory->get($this->entityType())
->condition('feeds_item.target_id', $feed->id())
// ->condition('feeds_item.imported', REQUEST_TIME -1, '<')
->execute();
}
So actually there is no condition hence all node get deleted for the selected feed.
Also there should be a created field in schema and nodes should be expired based on created date of node not imported or we could add an option for both.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff-2803057-12-13.txt | 849 bytes | MegaChriz |
#13 | feeds-expire-feature-deletes-all-imported-items-2803057-13.patch | 9.5 KB | MegaChriz |
| |||
#12 | interdiff-2803057-10-12.txt | 6.15 KB | MegaChriz |
#12 | feeds-expire-feature-deletes-all-imported-items-2803057-12.patch | 9.49 KB | MegaChriz |
| |||
#10 | interdiff-2803057-08-10.txt | 1.51 KB | MegaChriz |
Comments
Comment #2
MadSciencePro CreditAttribution: MadSciencePro commentedI've covered all the emotions this morning. I got my calendar RSS feed importing and I was elated. Then, I tried to expire after a year and discovered everything just gets deleted. Glad I found this post. Moment of panic over.
Comment #3
handkerchiefAre there any news about this? According to my tests it still doesn't work.
Comment #4
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI think that \Drupal\feeds\Feeds\Processor\NodeProcessor should override
\Drupal\feeds\Feeds\Processor\EntityProcessorBase::getExpiredIds()
and a condition on created date. This is similar to how this is solved in the D7 version of Feeds, where the node processor overrides the methodexpiryQuery()
.Or perhaps the
\Drupal\feeds\Feeds\Processor\EntityProcessorBase
class should check if the target entity type has a property called "created" and only provide the "expire" option if it has? In this case the condition on created date could be added to this class instead of the class for the node processor.Patches are welcome. I have no plans to work on this soon myself.
Comment #5
handkerchiefI have changed this code and it works for me:
Comment #6
cgmonroe CreditAttribution: cgmonroe as a volunteer commentedI needed this to work so I dug into it. I don't think that we need to do all the overrides and checks mentioned above. In the D8 version, there is an imported field on any entity imported. The delete after X time has passed is based on this.
FYI - I am using this with my own Non-node entity type processor with no problems.
One thing I noticed in creating the patch. The REQUEST_TIME variable has been deprecated. So I converted the REQUEST_TIME references in the Class to use:
Debated on turning this into a plugin argument for injection purposes, but that seemed like overkill for this service.
Attached is the patch.
Comment #7
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThanks for working on this, @cgmonroe. Perhaps with this, the automated tests could be updated. There are several placeholders in the tests for the expire feature:
Drupal\Tests\feeds\Kernel\Entity\FeedTest::testStartBatchExpire()
Drupal\Tests\feeds\Kernel\Feeds\Processor::testGetExpiredIds()
Drupal\Tests\feeds\Kernel\Feeds\Processor::testExpireItem()
Drupal\Tests\feeds\Unit\FeedExpireHandlerTest
Comment #8
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedRemoved
markTestIncomplete()
calls for expire related tests. Some tests may fail.Comment #10
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedFixed some errors in the test 'FeedExpireHandlerTest': The handler wasn't initiated in
setUp()
and the call toexpireItem()
missed the second parameter.Comment #12
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedWorked on FeedExpireHandlerTest. Added missing docs.
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedCoding standards.
Comment #15
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedCommitted #13.