[pmwiki-users] Weird one for those that use the attachtable cookbook
Petko Yotov
5ko at 5ko.fr
Thu Oct 15 13:26:56 PDT 2026
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');
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
--
If you upgrade : https://www.pmwiki.org/Upgrades
On 15/10/2026 19:44, Christopher Cox wrote:
> On 10/15/26 4:32 AM, Petko Yotov wrote:
>> I can't reproduce this.
>
> To reproduce on a pmwiki with per page downloads defined by:
>
> $UploadPrefixFmt = '/$Group/$Name';
>
> You need markup on pages of the same Group name that produce artifacts
> into the uploads area. That is a markup that produces
> uploads/Group/Name/blah-artifact.txt (for example).
>
> So, in the case of my private recipe, I see the following in that
> directive:
>
> $dirpath =
> $FarmD . '/' .
> FmtPageName(
> $UploadFileFmt,
> $pagename
> );
>
> And that is what is used for determining there the artifacts of the
> directive are placed. So, when attachtable does whatever it does....
> I'm seeing the directive get fired off as if each page of the Group is
> being processed, but the dirpath seemingly is for the page of the
> attachtable. So viewing (:attachtable:) on Test/Name1 results in
> processing of directives on Test/* with all the dirpaths (above) being
> set to Test/Name1.
>
> So, not sure why attachtable is activating all pages of the Group, and
> want to know how to prevent (or do correctly) the upload pathing in my
> recipe to work with the page where the markup actually lives rather
> than whatever attachtable is doing.
>
>
>>
>> On a blank PmWiki 2.7.6, in config.php, I have enabled the latest
>> Attachtable, and have this for per-page uploads:
>>
>> $UploadPrefixFmt = '/$Group/$Name'; # enable per-page uploads
>>
>> Note the single quotes.
>>
>> In Site/UploadQuickReference I added (:attachtable:).
>>
>> When I attach a file to Main.HomePage?action=upload, it is listed
>> there.
>>
>> When I attach a file to Main.WikiSandbox?action=upload, it is listed
>> there. The file attached to HomePage is not listed.
>>
>> Adding more files to either page does not make them appear in the
>> other page.
>>
>> What happens if you revert to (:attachlist:) in UploadQuickReference?
>>
>> If $UploadPrefixFmt is correctly set in config.php (not in
>> Group.Page.php), I suspect something else is interfering. See the
>> first entry on the page Troubleshooting on how to track it:
>>
>> https://www.pmwiki.org/wiki/PmWiki/Troubleshooting
>>
>> Petko
>>
>
>
> _______________________________________________
> 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