It's a common workflow to iterate over all Org headings in a given file, archiving those marked with the "DONE" keyword. The only problem is that archiving changes the structure of the file you're operating on, so if you have test.org:

    * DONE A
    * DONE B
    * DONE C
    * DONE D

A will be archived, moving [B, C, D] up, with point on B. Then, point is advanced to the next heading, so B gets skipped in favor of C getting archived. The end result is B and D remaining in the file instead of being archived.

In Org 9.4.4, you can fix this issue with a snippet like this:

(defun my-org-archive-done-tasks ()
  "Archive all top-level tasks with the DONE keyword in the current file."
  (interactive)
  (org-map-entries
   (lambda ()
     (org-archive-subtree)
     (setq org-map-continue-from (org-element-property :begin (org-element-at-point))))
   "LEVEL=1/DONE"
   'file))

...where you set org-map-continue-from in order to avoid skipping every other heading. However, upon updating to Org 9.5.2-gd01235, this function no longer works - if you have a file like test.org above, eval "my-org-archive-done-tasks", and try to run it on the file, every other heading is still skipped. I verified this by trying this function on test.org twice, first after running "emacs -Q", and then after doing "emacs -Q -l ~/.emacs.d/straight/repos/straight.el/bootstrap.el" and "M-x straight-use-package org"

I believe this is a result of recent additions in org-scan-tags - I hit a dead end there while trying to determine the exact cause of the change (the caching stuff that was added is spooky for a new user like me).

Is the snippet above no longer expected to work in Org 9.5.2 due to the logic for mapping over entries having changed, or is this a bug? If it's the former, what's the intended way of archiving all DONE tasks in a file now?

Emacs   : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4) of 2021-03-26
Package: Org mode version 9.5.2 (9.5.2-gd01235 @ /home/john/.emacs.d/straight/build/org/)

(And the function above *does* work in Package: Org mode version 9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/))

Best,
John