Memory allocation issue with some API requests when plugin is active
-
I have issues with memory limit on a server during some requests when your plugin is active. The problem is gone once I deactivate it.
(It concerns some REST API and WPGraphQL API requests. I had allocated 1024M of memory and it wasn’t enough)Analyze, please, even with help of LLM like Claude the plugin’s code and find and address its weak points. There is so many people using this plugin that any optimization can really make a world-wide impact.
For example:
public function forbidden_slugs() {
$wp = new \WP;
return array_merge( $wp->public_query_vars, $wp->private_query_vars );
}Problem: Creates a new
WPinstance on every call. TheWPclass is a core WordPress object that can be heavy. This method is called during slug validation, potentially multiple times per request.$request = parse_url( rawurldecode( $_SERVER['REQUEST_URI'] ) );Problem: This parsing happens multiple times in plugins_loaded() and wp_loaded() on every request. No caching mechanism exists.
global $current_user;
if ( ! is_user_logged_in() && is_wp_error( wp_authenticate_username_password( null, $current_user->user_login, $_POST['post_password'] ) ) ) {Problem: Accesses
$current_user->user_loginwhen user is NOT logged in. This could cause undefined property access and potential memory allocation issues.etc.
You must be logged in to reply to this topic.