• Resolved adaddario

    (@adaddario)


    Hi!

    I’ve created a PHP script where I can see only a list of posts that have the category “archived”.
    The posts needs to be “expired”, and when this happens, the plugin needs to handle the expiration of that post and remove all the categories present (becouse i dont what the post to be reached outside the archive page where is correctly listed and handled) and assign the category “archived” to my expired post.

    Where is the problem?

    Well, after hours trying to understand what the problem is, the solution is:
    The plugin cannot assign ANY post category to the post when the CronEvent gets triggered.

    To reach this point I’ve checked many times the post category creation, even assigned manually, by query in the wp_term_relationships table, the new category create for debug purpose, to the article to see if theres some kind of problem when the plugin or wp go to assign a category to the post, but everything is fine and works properly.

    I also have activated the debug/log mode inside the plugin.
    This is what comes out when I try to:
    – Remove all existing categories, and add new categories.
    – Keep all existing categories, and add new categories.
    – Keep all existing categories, except for those specified in this change.

    ___________________________________________________

    LOG:

    2021-10-28 13:09:20	2403 -> FAILED category-add Array ( [expireType] => category-add [category] => Array ( [0] => 120 [1] => 7 [2] => 10 ) [categoryTaxonomy] => )
    2021-10-28 13:08:25	2403 -> SCHEDULED at Gio, 28 Ott 2021 11:09:00 +0200 (1635419340) with options Array ( [expireType] => category-add [category] => Array ( [0] => 120 [1] => 7 [2] => 10 ) [categoryTaxonomy] => ) no error
    2021-10-28 13:06:02	2403 -> FAILED category-add Array ( [expireType] => category-add [category] => Array ( [0] => 12 ) [categoryTaxonomy] => )
    2021-10-28 13:05:19	2403 -> SCHEDULED at Gio, 28 Ott 2021 11:06:00 +0200 (1635419160) with options Array ( [expireType] => draft [category] => Array ( [0] => 120 [1] => 7 [2] => 10 ) [categoryTaxonomy] => ) no error
    2021-10-28 13:04:03	2403 -> PROCESSED draft Array ( [expireType] => draft [category] => Array ( [0] => 120 [1] => 7 [2] => 10 ) [categoryTaxonomy] => )
    2021-10-28 13:03:55	2403 -> SCHEDULED at Gio, 28 Ott 2021 11:04:00 +0200 (1635419040) with options Array ( [expireType] => category-add [category] => Array ( [0] => 120 ) [categoryTaxonomy] => ) no error
    2021-10-28 13:02:26	2403 -> FAILED category-add Array ( [expireType] => category-add [category] => Array ( [0] => 120 ) [categoryTaxonomy] => )
    2021-10-28 13:01:33	2403 -> SCHEDULED at Gio, 28 Ott 2021 11:02:00 +0200 (1635418920) with options Array ( [expireType] => category-add [category] => Array ( [0] => 120 ) [categoryTaxonomy] => ) no error
    2021-10-28 12:52:25	2403 -> FAILED category Array ( [expireType] => category [category] => Array ( [0] => 120 ) [categoryTaxonomy] => )
    2021-10-28 12:51:31	2403 -> SCHEDULED at Gio, 28 Ott 2021 10:52:00 +0200 (1635418320) with options Array ( [expireType] => category [category] => Array ( [0] => 120 ) [categoryTaxonomy] => ) no error

    ___________________________________________________

    I’ve also noticed that the plugin handles WRONG the Hours.
    In the edit/creation page of the post the time is in UTC.
    in the fast edit section of the post the time is handled in local time.
    the time is also some minutes wrong when reported in the log. (-30 min if im correct.)

    Since I already know what the problem is, but have spent time to know all this, I’m writing here in search of a solution from the dev and to help other people with the same problem.

    Thanks.

    edit: I’ve also read this wiki: https://publishpress.com/knowledge-base/troubleshooting-unpublish/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter adaddario

    (@adaddario)

    ISSUE UPDATE:

    We found that the problem is the IF wrote on line 841 in the file ‘post-expirator.php’ contained in ‘\wp-content\plugins\post-expirator’.

    the IF statement return FALSE, and I dont know why. The category is created via the category settings inside the section “posts > categories”.

    Forcing TRUE in that IF, everything works as it should.

    We tested the plugin on a new enviroptment and the result is the same, with the same error.
    We also tried logging errors generated from PHP / WP, and the only errors logged are these, and doesnt look relevant to the problem, just a random error.

    LOG:

    [29-Oct-2021 08:47:10 UTC] PHP Warning: require_once(C:\xampp\htdocs\wordpress\wp-content\plugins\post-expirator\classes/post-expirator-debug.php): failed to open stream: No such file or directory in C:\xampp\htdocs\wordpress\wp-content\plugins\post-expirator\classes\Display.class.php on line 131
    [29-Oct-2021 08:47:10 UTC] PHP Fatal error: require_once(): Failed opening required ‘C:\xampp\htdocs\wordpress\wp-content\plugins\post-expirator\classes/post-expirator-debug.php’ (include_path=’C:\xampp\php\PEAR’) in C:\xampp\htdocs\wordpress\wp-content\plugins\post-expirator\classes\Display.class.php on line 131

    I’m here for some solutions, or tips.

    Thanks.

    Thread Starter adaddario

    (@adaddario)

    if ( ! isset( $categoryTaxonomy ) || $categoryTaxonomy === ‘category’ ) {}

    this is the check that returns false, whatever action we do using categories in expiration settings.

    elseif ( $expireType === ‘category-add’ )
    {
    if ( ! empty( $category ) )
    {
    if ( ! isset( $categoryTaxonomy ) || $categoryTaxonomy === ‘category’ || true)

    Plugin Author Steve Burge

    (@stevejburge)

    Thanks for such a helpful reply @adaddario

    We’ve had reports of this category problem before and had been working towards a fix in the next release. I’ve moved your code to our Github repo and we’ll work on a fix: https://github.com/publishpress/PublishPress-Future/issues/170

    Thanks so much for taking the time to reseach this and post a solution. It’s an enormous help.

    Thread Starter adaddario

    (@adaddario)

    Thanks!

    Take note that the code in the last comment, is just the code on line 841 in the file ‘post-expirator.php’ contained in ‘\wp-content\plugins\post-expirator’, so it’s the code already present in the plugin.

    What we’ve done is just do a bypass in the IF statement, to resolve momentarily the problem, inserting the ” || true ” inside the IF, since the IF was always returning FALSE and we dont know the reason, but looking at our site it shouldnt.

    Maybe the IF is correct doing it wrong, because the logic is wrong. We dont know, we just know that the result shoukd be true and not false.

    We wait the fix, in the next release.
    Have a nice day!

    Plugin Author andergmartins

    (@andergmartins)

    Thanks, @adaddario we found the bug and fixed it.
    We are planning a release for this week.

    Thread Starter adaddario

    (@adaddario)

    Wonderful!

    I’m very happy to have helped even a little with the fix!
    Thanks for advising me about the new release! ??

    Plugin Author Steve Burge

    (@stevejburge)

    Thread Starter adaddario

    (@adaddario)

    Hi steve!

    I tested the beta right now, seems OK, and working right!
    All the problems I was having, seems gone!

    Appreciate the better translation inside the post full edit page!

    Thanks!

    Plugin Author Steve Burge

    (@stevejburge)

    Thanks @adaddario. Your feedback was very helpful here and the changes are released in version 2.6.2.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Post Expirator unable to handle correctly expiration by category (FAILED in log)’ is closed to new replies.