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

Object Cache not purged #261

Closed
Chrico opened this Issue Jun 19, 2017 · 1 comment

Comments

2 participants
@Chrico
Member

Chrico commented Jun 19, 2017

Version Information

  • PHP: any
  • WordPress: latest
  • MLP: 2.6.x

Steps to Reproduce

  1. Clean installation of a Multisite with min. 2 connected Blogs (e.G. DE <-> EN)
  2. Add dropin object-cache.php with some persitant cache (Memcache, APC(u), ..)
  3. Create a new post (e.G. post-type=page) in DE
  4. Create a new post (e.G. post-type=page) in EN
  5. Insert into frontend:
mlp_show_linked_elements( [
	'echo'              => false,
	'link_text'         => 'language_short',
	'show_current_blog' => true,
] );
  1. View post DE.
  2. mlp_show_linked_elements prints the link to home_url() for EN Blog
  3. Visit edit-post of DE post, connect the EN post and save.
  4. View post DE again.

What I Expected

The mlp_show_linked_elements() should now show the EN page in navigation.

What Happened Instead

The mlp_show_linked_elements() does still show the link to the EN home page.

Why?

This happens, because mlp_show_linked_elements() calls internally Mlp_Helpers::show_linked_elements() which calls $api->get_translations().

The method Mlp_Language_Api::get_translations() uses interally wp_cache_set() to store the results based on the $args which are the cache key.
Sadly it is not purged when a Post is updated/created/deleted. The key generation is also not safe to trust, because it does not have any context where it is used. The output can vary on every page (includes Archive, Single, CPT, ..) in frontend.

@Chrico Chrico added the bug label Jun 19, 2017

@tfrommen tfrommen added the languages label Jun 20, 2017

@tfrommen tfrommen added this to the v2.6.0 milestone Jun 20, 2017

tfrommen added a commit that referenced this issue Jun 20, 2017

Don't cache translations in language API. #261
This follows the logic in MLP 3.
Close #261.
@tfrommen

This comment has been minimized.

Show comment
Hide comment
@tfrommen

tfrommen Jun 23, 2017

Contributor

Fixed in e9b0735.

Contributor

tfrommen commented Jun 23, 2017

Fixed in e9b0735.

@tfrommen tfrommen closed this Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment