pods icon indicating copy to clipboard operation
pods copied to clipboard

Bug: Archive Remains when Enable Archive is unchecked

Open jimtrue opened this issue 7 years ago • 10 comments

Issue Overview

After checking 'Enable Archive Page' (and providing an Archive Page Slug Override) in Edit Pods, Advanced Options, archive is enabled. Unchecking (to disable the archive), the archive remains 'enabled' in WordPress, even though Pods Admin shows the archive is not 'Enabled'.

Expected Behavior

Disabling Archive should NOT leave it 'enabled' (has_archive should still represent as 'false' and there should not be a rewrite rule that points to the archives.

Current Behavior

Enabling Archives, enables archive. Unchecking 'Enable Archive Page' leaves the archive enabled.

Archive is Unchecked screenshot 2019-02-26 08 23 59

View Tests (View Archive is still available screenshot 2019-02-26 08 24 19

Archive Front-end Post Type Archives: Tests is still visible screenshot 2019-02-26 08 24 34

Steps to Reproduce (for bugs)

  1. Create a Custom Post Type
  2. Enable Archive under Advanced Options, 'Enable Archive Page'. Save and verify it works.
  3. Edit pod, and Uncheck 'Enable Archive Page'. Save and Pods Settings, Clear Cache (just in case)
  4. Visit Custom Post Type and see that View Archives is still available.

Current Pods Version 2.7.12

jimtrue avatar Feb 26 '19 13:02 jimtrue

This was reported on Slack today and validated locally by me.

jimtrue avatar Feb 26 '19 13:02 jimtrue

@jimtrue: I'm curious if clearing the Pods cache straightens it out.

pglewis avatar Feb 26 '19 18:02 pglewis

@pglewis Please see notes above in the issue. Clearing the pods cache doesn't fix this.

jimtrue avatar Feb 26 '19 18:02 jimtrue

Ah, I did read through, just missed that bit.

pglewis avatar Feb 26 '19 18:02 pglewis

Hi, I am seeing the same error listed above.

I enabled the archive page for a pod. Later on I decided I didn't want the archive page. I unchecked the "Enable Archive Page" under Advanced Options. Unfortunately the archive page still operates.

Thanks

gberg927 avatar Apr 26 '19 13:04 gberg927

I resolved it by enabling archive page, then remove the text in the 'slug' field that appears and disabling the archive page again. Then go to settings--> permalinks and click save (as far as I know this triggers permalink rewrites). That solved it for me.

Driekes avatar Jan 03 '21 15:01 Driekes

Hi @Driekes This indeed sounds like a permalink cache issue.

@sc0ttkclark

  • Line that triggers cache flush: https://github.com/pods-framework/pods/blob/main/classes/PodsAPI.php#L2401
  • Line that triggers cache refresh transient: https://github.com/pods-framework/pods/blob/main/classes/PodsAPI.php#L9229
  • Actual rewrite refresh (after wp_loaded): https://github.com/pods-framework/pods/blob/main/classes/PodsInit.php#L1469

What I noticed is that using the function flush_rewrite_rules() defaults to a hard flush while we only do a soft flush. A particular reason for this?

EDIT: I also don't really understand why we use a transient for this while WP already has the whole action handling done for flushing rewrites, you can just run flush_rewrite_rules() and WP handles the rest right?

JoryHogeveen avatar Jan 05 '21 13:01 JoryHogeveen

Might it not be the case that the slug is used even if the archive checkmark is set to off? Not sure if this is just a cache issue, but you'll know better 👍🏻

Driekes avatar Jan 05 '21 17:01 Driekes

Came here to file this same issue. I too had to make sure to remove the text from the custom Slug Override field before unchecking the box. That was enough to fix the issue, without having to flush permalinks.

corypina avatar Jul 26 '21 16:07 corypina

Patch can be tested! See pull request: #6069

JoryHogeveen avatar Jul 28 '21 07:07 JoryHogeveen