Re: cache vignettes : images différentes entre espace public/privé

Julien Lanfrey <[email protected]>
Newsgroups gmane.comp.web.spip.devel
Message-ID <CADByJ-nDqOBzUQ_O1+zxr0fE1SvQa8sk6jhEtkxeHiq-=JTPkg@mail.gmail.com>
Super Matthieu, je te remercie bcp !!

Avec autour de 250 000 photos sur un site, ça m'intéresse pas mal !
J'ai testé ton code en local et ça ne marche bien.

J'ai juste du faire une petite adaptation pour que fonctionne aussi en
local sous windows...
Le coupable vient du ecrire/inc_version.php qui rajoute un "/" à la fin du
_ROOT_RACINE.

Ce qui au niveau du code génère ceci :
_ROOT_RACINE => "C:\...\localweb\projects\spip3/" => un slash final inversé
pour windows
realpath($fichier) => "C:\...\localweb\projects\spip3\IMG\arton9306.jpg"

et donc le "strpos" ne passe pas.

Pb sous windows uniquement donc.
...qu'on peut résoudre comme ça :

// rtrim : éviter le mélange des '/' et '\' sous windows...
if (strpos($f = realpath($fichier), rtrim(_ROOT_RACINE, '/')) === 0) {
    $identifiant = substr($f, strlen(_ROOT_RACINE));
}

pour que ça fonctionne partout.


Julien




Le 2 juillet 2017 à 14:11, Matthieu Marcillaud <[email protected]> a écrit :

> Le 02/07/2017 à 13:18, Matthieu Marcillaud a écrit :
>
>> Le 02/07/2017 à 13:05, Matthieu Marcillaud a écrit :
>>
>> Oui, c'est bien ce que j’imaginais aussi.
>>> J’ai même un patch là éventuellement.
>>>
>>
> Bon, j’ai envoyé cela https://core.spip.net/projects
> /spip/repository/revisions/23632 à tester tout de même.
>
> Et finalement j’ai utilisé strpos qui est signalé plus rapide que strncmp
> dans cet usage (http://php.net/manual/fr/function.strncmp.php#121036).
>
> MM.
>
> _______________________________________________
> liste: http://listes.rezo.net/mailman/listinfo/spip-dev
> doc: http://www.spip.net/
> dev: http://trac.rezo.net/trac/spip/
> irc://irc.freenode.net/spip
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.