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

When the Menu Model has been filtered to be public, menu's aren't being invalidated from the cache #220

Closed
jasonbahl opened this issue May 17, 2023 · 0 comments · Fixed by #221
Assignees
Labels
bug Something isn't working

Comments

@jasonbahl
Copy link
Collaborator

Steps to reproduce:

Filter the "Menu" Models to make them public:

add_filter( 'graphql_data_is_private', function( $is_private, $model_name, $data, $visibility, $owner, $current_user ) {

	if ( 'MenuObject' === $model_name || 'MenuItemObject' === $model_name ) {
		return false;
	}

	return $is_private;

}, 10, 6 );

Create a menu, but don't assign it to a location (this would be a private menu by default).

Query for the menu:

{
  menu(id: "Menu with no Location", idType: NAME) {
    id
    name
    menuItems {
      nodes {
        id
        label
      }
    }
  }
}

See that you can get the menu as a public user:

CleanShot 2023-05-17 at 14 38 57

Enable Error Logging for WPGraphQL Smart Cache.

Update the menu you just queried.

PROBLEM

See that there are no purge events for the menu being edited, even though it's been filtered to be a Public model.

EXPECTATION

I would expect for a menu that's been filtered to be public to log an event such as:

[17-May-2023 20:35:37 UTC] (graphql_purge) key: dGVybTo0MA==, event: updated_nav_menu, user: 1, page: /wp-admin/nav-menus.php
[17-May-2023 20:35:37 UTC] (graphql_purge) key: skipped:term, event: updated_nav_menu, user: 1, page: /wp-admin/nav-menus.php
@jasonbahl jasonbahl self-assigned this May 17, 2023
@jasonbahl jasonbahl added the bug Something isn't working label May 17, 2023
jasonbahl added a commit that referenced this issue May 18, 2023
…-private-even-if-model-has-been-filtered-to-public

fix: updating menus not assigned to locations doesn't purge menus, even if their model is public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant