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

Christopher Cox chriscox at endlessnow.com
Fri Oct 16 11:12:03 PDT 2026


So, what I did in my recipe to "fix", as it creates artifacts in the per page 
uploads area where the markup resides. The references behavior of attachtable
Does MarkupToHTML, instead of using $pagename, I switch to using $sourcepage, 
where I defined that as:

$sourcepage = $pagename;
if (!empty($GLOBALS['MarkupToHTML']['pagename']))
         $sourcepage = $GLOBALS['MarkupToHTML']['pagename'];

That seemed to prevent all those reference html gens that attachtable does from 
creating artifacts inside the page containing attachtable.

Not sure if this "pmwiki correct" though.


On 10/15/26 6:13 PM, Christopher Cox wrote:
> I've attached badboy2-php.txt
> 
> (:badboy2:)
> Some text
> (:badboy2end:)
> 
> with references enabled on attachtable, tell me what you discover if you have
> that markup on BadBoy/PageOne and then you view attachtable on BadBoy/PageTwo.
> 
> 
> On 10/15/26 4:40 PM, Christopher Cox wrote:
>> 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
>>>
>>
>>
>> _______________________________________________
>> pmwiki-users mailing list
>> pmwiki-users at pmichaud.com
>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users




More information about the pmwiki-users mailing list