Skip to content

Commit

Permalink
Merge pull request #437 from mrrobot47/fix/auth-delete
Browse files Browse the repository at this point in the history
Add auth cleanup patch in site delete
  • Loading branch information
mrrobot47 committed Sep 13, 2024
2 parents a1be7c3 + 8be88f9 commit eb0572f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use EE\Model\Cron;
use EE\Model\Site;
use EE\Model\Option;
use EE\Model\Auth;
use EE\Model\Whitelist;
use Symfony\Component\Filesystem\Filesystem;
use function EE\Site\Cloner\Utils\check_site_access;
use function EE\Site\Cloner\Utils\copy_site_db;
Expand Down Expand Up @@ -363,6 +365,32 @@ protected function delete_site( $level, $site_url, $site_fs_path, $db_data = []
}
}

$site_auth_file = EE_ROOT_DIR . '/services/nginx-proxy/htpasswd/' . $site_url;
if ( $this->fs->exists( $site_auth_file ) ) {
try {
$this->fs->remove( $site_auth_file );
} catch ( \Exception $e ) {
\EE::warning( $e );
}
reload_global_nginx_proxy();
}

$whitelists = Whitelist::where( [
'site_url' => $site_url,
] );

foreach ( $whitelists as $whitelist ) {
$whitelist->delete();
}

$auths = Auth::where( [
'site_url' => $site_url,
] );

foreach ( $auths as $auth ) {
$auth->delete();
}

if ( Site::find( $site_url )->delete() ) {
\EE::log( 'Removed database entry.' );
} else {
Expand Down

0 comments on commit eb0572f

Please sign in to comment.