Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: An empty string is not a valid cache key #390

Open
mmorris8 opened this issue Feb 11, 2025 · 1 comment
Open

BUG: An empty string is not a valid cache key #390

mmorris8 opened this issue Feb 11, 2025 · 1 comment

Comments

@mmorris8
Copy link

mmorris8 commented Feb 11, 2025

I've fixed a bug that was opened in 2017 it's nowhere near close to the front page, but I fear this won't be noticed because that thread is older than dirt, digitally speaking.

in /js/src/cache.js at line 36:

var value = that.get( id, store );

Change to

var value = id === '' ? true : that.get( id, store );

That will result in the function looking like this

Cache.prototype.getUncached =  function( ids, store ) {
	store = typeof store === "undefined" ? "default" : store;

	var that = this;

	ids = _.uniq( ids );

	return ids.filter( function( id ) {
		var value = id === '' ? true : that.get( id, store );

		return value === false;
	} );
};

This function will get called with ['']. It needs to return an empty array when this happens because '' should never be a valid key. If this isn't done this plugin spams the life out of the backend with around 40 initial queries and a new query every keystroke. The response is always going to be empty because an attachment can't have that key.

Please fix this. I do not like having to re-apply stuff like this each time I update a plugin. While this bug is a mere nuisance on a small site, the site I run has 100 staffers and around 10,000 page builds / day between them and the public. This bug has been dragging the site for awhile now.

@josevarghese
Copy link

Hi @mmorris8

Thank you for opening the issue! Kindly please submit a pull request with your changes with test instructions, and our development team will review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants