Open andykamezou opened 9 months ago
TBH, I'm not sure the plugin should alter the field... ?
If I understand this correctly, the plugin works as designed and publishes/unpublishes as described in the field, right?
If I understand this correctly, the plugin works as designed and publishes/unpublishes as described in the field, right?
Yes, it seems to be working as you designed.
But because both autopublish
and autounpublish
fields still have values, the plugin keeps re-publishing the same draft and then immediately unpublish it.
To be clear, this will only happen when the page is set to use both autopublish
and autounpublish
.
.
I think that was unnecessary behaviour because there is no reason to re-publish the same draft and then immediately unpublish it, especially when the date & time for both autopublish
and autounpublish
fields already passed a long time ago.
For example, my test page has been auto-published and auto-unpublished last month. I had to manually clear the fields to make sure the page was not included again in the next cron. Or else the plugin will keep trying to re-publish the page until the end of the world~
That one test page also produces about 750kb of autopublish log after 3 weeks of cron every 15 minutes. There's probably someone out there who frequently uses both fields for many pages and didn't realise that their log files are growing bigger.
.
So what I was thinking is if I have to fix it on my own, the quickest solution is probably clearing the autopublish
field after successfully auto-publish the page. The same goes for when auto-unpublish the page.
Hmmm. I'm still in dubio about actually altering the content file.
Maybe add a check if there's
don't re-publish?
Yeah, maybe something like that should work too. As the issue is caused by drafts that has both publish and unpublish time set, we need extra check to exclude certain drafts from the autoPublishedDrafts
collection.
When filtering autoPublishedDrafts
collection, don't include the draft if :
$publishTime
and $unpublishTime
setSomething like that?
I recently launched my first Kirby website and today I realised that the autopublish.log file is larger than expected. So I looked into it, and I saw these in the log:
It was the test page that I made to test this plugin last month. The plugin has been publishing and unpublished the same test page again and again.
I assume it's because despite the page has been published/unpublished, the auto-publish and auto-unpublish fields still have a date and time set in it. So on every cron cycle, the plugin will:
Maybe the plugin needs to clear the date & time fields after publishing/unpublish the page.