Support » Plugin: Optimize Database after Deleting Revisions » Problem with the scheduler

  • Resolved jgdaimiel

    (@jgdaimiel)


    Hello,
    I’m quite new in wordpress, and I have installed this plugin to delete some old revisions. I’m trying to use the scheduler to do so. Everything seems to be ok, the task is scheduled correctly but when the time comes nothing happens, no items are modified.
    Is there anyone also experimenting this problem?

    I looked into the code and I have some doubts.
    File odb_cleaner.php
    There is this piece of code where the delete is executed in the function odb_delete_revisions($scheduler, $action = ‘run_detail’)

    if ($action == 'run_summary' || $action == 'run_detail') {
    						$sql_delete = sprintf ("
    						DELETE FROM %sposts
    						 WHERE <code>ID</code> = %d
    						", $results[$i]['site'], $results_get_posts[$j]->ID);
    						
    						$wpdb->get_results($sql_delete);
    					}

    It seems like this is never executed if the clean is shceduled, because $action is empty.

    When you schedule the clean, the plugin calls odb_start(true). In this function the $action variable is set to ” by default and it never changes its value when the clean is from wp_cron.
    The function odb_delete_revisions sets a default value for $action, but the value passed to this function is an empty string, so I think it doesn’t use the default value.

    I got it working by adding these lines at the beginning of the odb_delete_revisions function:

    if($scheduler && $action == ''){
    			$action = 'run_detail';
    		}

    Could this be the reason of the problem? Or is there something that I didn’t see?

    Thank you.

    • This topic was modified 1 month ago by  jgdaimiel.
Viewing 1 replies (of 1 total)
  • Plugin Author cageehv

    (@cageehv)

    Hey jgdaimiel,

    Good catch!

    I fixed the bug and released a new version, 4.8.1.

    Thanks for your feedback!

    peace,
    Rolf

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.