Skip to content

Commit

Permalink
Merge pull request #430 from mrrobot47/cleanup/cron
Browse files Browse the repository at this point in the history
Delete cron on site delete
  • Loading branch information
mrrobot47 authored Nov 10, 2023
2 parents f51f198 + 51f54ab commit 724d594
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AcmePhp\Ssl\Certificate;
use AcmePhp\Ssl\Parser\CertificateParser;
use EE;
use EE\Model\Cron;
use EE\Model\Site;
use EE\Model\Option;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -323,6 +324,19 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
EE::exec( 'docker exec ' . EE_PROXY_TYPE . " bash -c 'rm -rf /var/cache/nginx/$site_url'" );
}

try {
$crons = Cron::where( [ 'site_url' => $site_url ] );
if ( ! empty( $crons ) ) {
\EE::log( 'Deleting cron entry' );
foreach ( $crons as $cron ) {
$cron->delete();
}
\EE\Cron\Utils\update_cron_config();
}
} catch ( \Exception $e ) {
\EE::debug( $e->getMessage() );
}

/**
* Execute before site db data cleanup and after site services cleanup.
* Note: This can be use to cleanup site data added by any package command.
Expand Down

0 comments on commit 724d594

Please sign in to comment.