humanmade / Cavalcade

A better wp-cron. Horizontally scalable, works perfectly with multisite.
https://engineering.hmn.md/projects/cavalcade/
Other
528 stars 46 forks source link

Possible Wrong Version Display and LOG disabling solution #122

Open danidorado opened 1 year ago

danidorado commented 1 year ago

Hi Guys, have you realised when you download the lastest version 2.0.2, the plugin.php file says version 2.0.0?

Is this just a typo on plugin.php file or are we downloading a wrong version?

In addition i'd like to ask if there's a way to disable the logs, it creates millions of rows at my set up and it has the databse constantly writting records, as i have several multisite installations with more than 200 sites.

Thanks in advance

rmccue commented 1 year ago

Is this just a typo on plugin.php file or are we downloading a wrong version?

Looks like we haven't updated it:

https://github.com/humanmade/Cavalcade/blob/87ff25e5f6a99b7d7c6626f966adceb086186c73/plugin.php#L8

In addition i'd like to ask if there's a way to disable the logs, it creates millions of rows at my set up and it has the databse constantly writting records, as i have several multisite installations with more than 200 sites.

There's no option for it, but you could use the filter to change the logger implementation to a no-op log class:

https://github.com/humanmade/Cavalcade-Runner/blob/0dfb42d505e9cd870a11366c49ee680d327c961a/inc/class-runner.php#L366-L375

Alternatively, you can run a task to clean old logs.

danidorado commented 1 year ago

so do you mean the code itself is updated to 2.0.2 but just the version reference is not updated on that particular line?

Just in case someone needs to implement the class to remove the log creation i've created this MU-plugin

/**

class NoOpLogger { public function __construct() { // No-op constructor. }

public function log( $message, $level = 'info', $context = array() ) {
    // No-op log method.
}

}

function my_custom_logger( $logger ) { if ( is_multisite() ) { // Si estamos en una instalación multisite, usa la clase NoOpLogger. return new NoOpLogger(); }

// Si no, usa la implementación predeterminada del logger.
return $logger;

}

add_filter( 'Runner.check_workers.logger', 'my_custom_logger' );