What's new
Xen Factory

Register today to become a member! Once signed in, you'll be able to start purchasing our products, ask questions, request support and suggest new ideas!

  • We are aware that a no permission error was shown when you tried to purchase in the last 2 days, this is now fixed.

Bug Resolved Double posting?

beerForo

Member
My only thought is, the leap year may have caused this?

But this month, March, I have double posts for the 24 hour announcement:
Yesterday at noon: You have 24 hours to enter before voting
Today at noon: You have 24 hours to enter before voting

No voting thread was created today. So I guess it will tomorrow? But not sure why this happened. Leap year? Thanks

I will post back after the voting post.
 

beerForo

Member
So I looked and the VOTE button is on the entries! This is correct, it should start today, but the post was not made. Only (2) of the 24 hours left post, as stated above.

Weird! It's like the wrong post was made. I double checked my message templates. That is not the issue.
 

Clement

Freaky Coder
Staff member
I checked at the code, the two called options are different so that's not the issue.

The post couldn't be posted twice, the check is done on a time period of 24H so it can't be called twice if the cron does run with 24H of difference between two times.
 

beerForo

Member
Okay

Yesterday's post was 12:06
Today's was 12:03

It looks like the cron ran early and caused it. Why would that happen? I actually have it set to run at 12:00. It ran 6 and 3 minutes late.
 

beerForo

Member
This still does not explain why no post of "Voting has started" was NOT posted today at 12:00. I guess because the cron. Seems buggy! It will probably post tomorrow, and voting has already started!
 

beerForo

Member
So, my voting started yesterday, but the post was made today:

12:01 - You have 7 days to vote

This post was made today at 12:01 PM ET, my cron is set at 12:00 (16:00:00 UTC). Is cron lag causing these issues? So an early one is less than a day, a late one is more than a day, etc? If so why is there cron lag? Thanks
 

Clement

Freaky Coder
Staff member
Yeah basically if the cron doesn't run at the exact same hour this can happen as I am basing the it from creation time and then computing delays of 24H for the different events.

I have no idea why the cron ran delayed, this is core xF stuff you should ask them.
 

beerForo

Member
Yeah right the first one double posted because it was still the first day when the "early" cron ran. But voting opened and the post for voting did not post until the next cron.

I will have to figure out why the cron runs all wacky! I'll let you know if I find out. Thanks
 

beerForo

Member
XF says:

"Hello

Cron tasks only run once someone has visited the site after the defined time.

If you want the time to be more accurate, you would need to visit the site at that time, or change the cron time to when the site is busy."

I already have it at a busy time. Do you have a solution? Can I use my cPanel to run the cron maybe? This is going to cause issues again.
 

beerForo

Member
So XF says the cron can run at any time after the set time, when someone is active on the site. So this can cause bug the way you have coded this add-on.

I talked to Sim over at XF about his cron add-on to see if it would help, and he let me know the best way to fix your add-on. See below.

Sim says:
"I think you're solving the wrong problem - the addon should store the last time the post was made so that it avoids making duplicate posts. This is what the data registry is for - to store information for addons to retrieve later.

Relying on a task to execute at an exact time is not a good approach IMO.

Algorithm would be something like this:

  1. create forum post, then in registry store creation time and a flag "24 hours left post" set to false
  2. once per day, cron task checks today's date vs date of created post
    1. if 20 days have passed, then
      1. if "24 hours left" flag is NOT set in registry, then
        1. create "24 hours left post"
        2. set "24 hours left post" flag to true
This way the "24 hours left" post is guaranteed to only get created once per month and it doesn't matter exactly what time the cron task runs each day."

I hope you can apply this fix so there's no more issues with double posting the "same" day, or opening the voting without the voting post (happened the next day). Crons can't be guaranteed to be exactly 24 hours apart, so when one is 23:59 minutes after the last, it is considered the same day and then it waits another 24 hours to post again so we can be waiting a whole day for the correct post.

Please let me know if this can be fixed, or, this problem will keep happening. Thanks!
 
Last edited:

Clement

Freaky Coder
Staff member
Yeah could do something like that to avoid the double post, not exactly how he suggested but in some way.

So yeah this can be fixed in a next release.
 

beerForo

Member
It would be great if your fix could prevent the double post, but also force the correct post or action.
Like with my case, it double posted the "24 hours left" post, and on the second day voting opened, but the vote starting post was not made until a day after that. All because cron was a couple minutes off. This can also cause the contest to run a day late or the notice, etc.
If a cron is set for 12:00, and it runs at 12:03, the next day 12:02 that is considered the same day so it should prevent the "double" action but force the next action that is supposed to happen on that day; a post, voting, or ending the contest, etc.

Maybe the actions should not be based on the post timestamps.

Anyway, thanks!
 

Clement

Freaky Coder
Staff member
That's the plan.
Don't expect a release in a very close future though, quite busy currently and lower time due to confinement in France.
 
Top