From 2cfa667a5232e0037853482ba629e3bcca84abce Mon Sep 17 00:00:00 2001 From: dhsathiya Date: Mon, 26 Dec 2022 11:55:24 +0530 Subject: [PATCH 1/3] Add WebP to cache static file block --- templates/config/nginx/main.conf.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/config/nginx/main.conf.mustache b/templates/config/nginx/main.conf.mustache index b9f810f9..7f104065 100644 --- a/templates/config/nginx/main.conf.mustache +++ b/templates/config/nginx/main.conf.mustache @@ -21,7 +21,7 @@ server { } # Cache static files - location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { + location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp)$ { add_header "Access-Control-Allow-Origin" "*"; access_log off; log_not_found off; From 731f8ccf99f410a5175fbd3a2b622bd68f887f2f Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 7 Feb 2023 11:00:03 +0530 Subject: [PATCH 2/3] Add migration for webp in existing sites Signed-off-by: Riddhesh Sanghvi --- ...0_site-command_nginx_add_webp_to_cache.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 migrations/container/20230207100940_site-command_nginx_add_webp_to_cache.php diff --git a/migrations/container/20230207100940_site-command_nginx_add_webp_to_cache.php b/migrations/container/20230207100940_site-command_nginx_add_webp_to_cache.php new file mode 100644 index 00000000..a578663c --- /dev/null +++ b/migrations/container/20230207100940_site-command_nginx_add_webp_to_cache.php @@ -0,0 +1,67 @@ +sites = Site::all(); + if ( $this->is_first_execution || ! $this->sites ) { + $this->skip_this_migration = true; + } + } + + /** + * Execute nginx config updates. + * + * @throws EE\ExitException + */ + public function up() { + + if ( $this->skip_this_migration ) { + EE::debug( 'Skipping nginx-config update migration as it is not needed.' ); + + return; + } + + foreach ( $this->sites as $site ) { + $main_conf_file = $site->site_fs_path . '/config/nginx/conf.d/main.conf'; + + if ( file_exists( $main_conf_file ) ) { + + $search = '|swf'; + $replace = '|swf|webp'; + + $file_contents = file_get_contents( $main_conf_file ); + + if ( strpos( $file_contents, $search ) !== false && strpos( $file_contents, 'webp' ) === false ) { + $file_contents = str_replace( $search, $replace, $file_contents ); + } + + file_put_contents( $main_conf_file, $file_contents ); + } + + } + } + + /** + * Bring back the existing old nginx config. + * + * @throws EE\ExitException + */ + public function down() { + } + +} From 51f54ab38675900f75980af709fc49bfc5ed8f5e Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Fri, 10 Nov 2023 15:51:26 +0530 Subject: [PATCH 3/3] Delete cron on site delete Signed-off-by: Riddhesh Sanghvi --- src/helper/class-ee-site.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/helper/class-ee-site.php b/src/helper/class-ee-site.php index 0cf4585c..585fcc79 100644 --- a/src/helper/class-ee-site.php +++ b/src/helper/class-ee-site.php @@ -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; @@ -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.