[pmwiki-users] Weird one for those that use the attachtable cookbook

Christopher Cox chriscox at endlessnow.com
Thu Oct 15 14:40:00 PDT 2026


On 10/15/26 3:26 PM, Petko Yotov wrote:
> I still could not experience a duplication of the uploads/ directories, but 
> found something probably related.
> 
> When Attachtable is configured to count the number of references for every file, 
> which is the default, it finds all other pages and calls MarkupToHTML with the 
> other $pagename for each page. This changes the global variable 
> $MarkupToHTML['pagename'] and from that point on, subsequent markups on the page 
> think they are on the last page Attachtable processed for the references.
> 
> So if I have in HomePage:
> 
> Attach:pic.jpg | picture exists and is shown
> 
> (:attachlist:) works, shows files attached to HomePage
> 
> (:attachtable:) works, shows files attached to HomePage, but the references 
> change $pagename to WikiSandbox
> 
> Attach:pic.jpg | picture does not exists in WikiSandbox
> 
> (:attachlist:) shows files attached to WikiSandbox
> 
> (:attachtable:) shows files attached to WikiSandbox
> 
> 
> After the first (:attachtable:), all links to uploads within Attach:, 
> (:attachtable:) and (:attachlist:) link to files attached to the last page the 
> first attachtable looked for file references. It just links to the other page, 
> does not seem to copy the other files to have them twice.
> 
> A quick fix would be to define the default data fields excluding 'references', 
> in config.php:
> $AttachtableDataFields = array('name', 'size', 'modtime', 'mimetype');

Thanks, yep, that fixed (worked around) the issue for now.  I tried making a 
very empty simulated cookbook, but, it didn't show the problem.. .sigh.  So, 
this will do "for now" until I can fully debug my recipe.

User error.  But worked around for now.


> 
> Alternatively, in the wiki page set (:attachtable data=name,size,modtime:) 
> without 'references'.
> 
> Another quick fix could be to modify mu_FmtAttachtable() this way:
> function mu_FmtAttachtable($m) {
>    \extract($GLOBALS["MarkupToHTML"]);
>    $out = \Keep(FmtAttachtable($pagename, $m[1]));
>    $GLOBALS["MarkupToHTML"]['pagename'] = $pagename;
>    return $out;
> }
> 
> I've added something similar in the core to push the current pagename to a stack 
> when starting, and at the end to pop it and reset $MarkupToHTML['pagename']. 
> This should work with attachtable and possibly other markup functions that may 
> call MarkupToHTML().
> 
> This can be tested now with the pre-release and should be available in 2.7.7 in 
> the next few days.
> 
> Petko
> 




More information about the pmwiki-users mailing list