Summary: PageExists cache $PageExistsCache becomes stale after new page created
Created: 2017-01-09 16:33
Status: Closed, added for 2.2.94
From: Peter Kay
Description: If you run PageExists("Main.Test"); and then use UpdatePage to create Main.Test, any future calls to PageExists will still return false, because $PageExistsCache has not been updated after UpdatePage.
The reverse might also happen: if a page is deleted after PageExists() is called, the cache will show the page still exists.
Peter Kay January 09, 2017, at 04:33 PM
One easy solution would be to add
And add the line "ClearPageExistsCache(
Peter Kay January 09, 2017, at 04:44 PM
After reviewing the entry, I may have to decline this feature request. Currently nothing prevents the core PmWiki to function properly, only a recipe may require the additional feature. Also, a recipe may have a number of different ways to create or delete pages: UpdatePage(), PostPage(), WritePage(),
I've traced every write I can find in the core pmwiki, and except for special files (page cache, last-modified, etc), all the file creation goes through the PageStore->write function. Adding ClearPageExistsCache(
I am aware the core functioning doesn't need the change, but someone writing a cookbook would like to be able to use the PageExists() function with confidence. The change would add very minimal overhead for core functioning, while allowing easier and safer expansions via recipes.
At the very least, the function ClearPageExistsCache should be created: as noted at line 1189 of pmwiki.php, $PageExistsCache might change or disappear someday. A function with a reliable name would ensure future functionality, and would be easily added to documentation for anyone using UpdagePage() or the PageStore functions. Alternately, the global variable $PageExistsCache could be enshrined as is for future use. Peter Kay January 23, 2017, at 10:38 PM
Fair enough, the cache will be cleared for the next version; no function, simple calls to unset the variables in write() and delete(). --Petko January 31, 2017, at 02:41 PM