[pmwiki-users] Questions about PTV and PTV mass edit

Petko Yotov 5ko at 5ko.fr
Wed Jul 3 12:48:06 PDT 2024


On 03/07/2024 19:27, ABClf wrote:
> Soon or late, I'm planning to text process some of my wiki.d files to
> correct ptv I have written with accented letters (my fault) ;
> I think I will use grep/sed like tools.
> 
> My question is :
> is it ok, safe, to mass edit files out of PmWiki ?

If it were me, I'd write a couple of PHP functions to do the mass 
replacement with the PmWiki API (maybe in portions, for a large set of 
pages). Let me know if I can assist.

The PmWiki file format is somewhat complex for editing outside of 
PmWiki. The whole text is on a single line, newlines and some characters 
are url-encoded, so it is not obvious to edit such files with grep, sed 
or other text utilities.

Another disadvantage if you edit the disk files, there will be no "diff" 
history entry for your change and you might be unable to revert to a 
version before that edit from within the wiki with "Page?action=diff".

> are date/time of files important for PmWiki ?

The last modification time for the disk file is normally not used by 
PmWiki, but I suspect some recipes use it, for example FastCache.

For PmWiki, the page file on the disk has an attribute (a line) 
"time=123456789" which is the Unix timestamp of the last modification 
from within PmWiki. This timestamp is used for "{$LastModified}" or 
"pagelist order=-time".

> do I have to use options to preserve original timestamp when mass 
> editing ?

If the external script does not modify the "time=123456789" attribute, 
for PmWiki that will be important.

If it is a PHP function editing with the PmWiki core API, the "time=" 
attribute is automatically set to the time of the edit. But if you need 
to keep the previous timestamp, it is possible to write a custom page 
store class that doesn't change it.

If you need to reset the last modification of the disk file after you 
edit it, you could use the "touch" utility from Bash, or the touch() 
function from PHP.

> how does PmWiki use PTV, when you call one from another page, or in
> pagelist : from pageindex

No.

> or from scanning every wiki.d files

Yes.

> (if I
> only modify ptv, out of PmWiki edit/save process, will I have to
> generate a new pageindex in order to get the new ptv usable ?)

PTVs are normally not indexed in .pageindex, only the page names, last 
modified times, and the list of words for searches.

Normally you don't need to generate .pageindex, PmWiki will generate it 
if it is not up to date.

The standard advice is if you mass-edit pages, you just delete 
.pageindex and let PmWiki regenerate it.

> (In my own case, generating a new .pageindex –almost 80 mo– is quite
> long and makes me anxious, thus I have to be cautious : if that works,
> don't break it).

The creation of .pageindex for many pages may indeed be long; if there 
are too many pages to index, PmWiki will only do it for up to 10 seconds 
then skip the rest. On the next page load, it will continue from where 
it was before. So you can just refresh any page, wait 10-12 seconds for 
it to finish, then refresh again and again until the refresh is almost 
instant.

Petko



More information about the pmwiki-users mailing list