Skip to content

Commit

Permalink
Merge pull request #14 from alleyinteractive/feature/500-status-code
Browse files Browse the repository at this point in the history
Prevent caching and exit with 1 when a plugin is missing
  • Loading branch information
srtfisher authored Dec 17, 2024
2 parents e390024 + ad3e4cd commit 18bff6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to `WP Plugin Loader` will be documented in this file.

## 0.1.6 - 2024-12-17

- When a plugin is not found, exit with a status code of 1 and send a `500`
status code header. This will prevent a fatal error from being cached

## 0.1.5 - 2024-09-25

- Ensure that the default cache key is unique to each installation. Previously
Expand Down
10 changes: 8 additions & 2 deletions src/class-wp-plugin-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,14 @@ protected function handle_missing_plugin( string $plugin ): void {
newrelic_notice_error( $error_message );
}

// Bye bye!
die( esc_html( $error_message ) );
// Send a 500 status code and no-cache headers to prevent caching of the error message.
if ( ! headers_sent() ) {
status_header( 500 );
nocache_headers();
}

echo esc_html( $error_message );
exit( 1 );
}

/**
Expand Down

0 comments on commit 18bff6b

Please sign in to comment.