Mailing List Archive

More fun with find_or_create_alternate()
Hi everybody,

I've just been fiddling with the fun parts of the
find_or_create_alternate() method to fix a bug. I've found a fix, but
thought I should add this to the list anyhow.

Here's the bug:

When the source image and target thumbnail image are in different OCs
with different URI formats, calling find_or_create_alternate() will
throw a URI-not-unique error.

This is because the URI generated for the initial find uses the source
image OC URI format, not the destination URI format.


Here's an example:

The original image is of type "Infrastructure image." That type is in
the "Includes" OC, with fixed URI. Here are the URI formats:

/%{categories}/includes/%{slug}/
/%{categories}/includes/%Y/%m/%d/%{slug}/

So the starting URI of my image is this:

/international/includes/a19new.gif


The element type for my thumbnail is "Auto-generated image." Which is in
the Web OC, with non-fixed URI, like this:

/%{categories}/%Y/%m/%d/%{slug}/

I'm expecting the thumbnail to have a URI like this:

/international/2011/07/14/a19new_90.gif

...but the lookup inside the find_or_create_alternate comes up with this
target URI instead:

/international/includes/2011/07/14/a19new_90.gif

No image with this URI exists, so it goes on to create one. This one has
the correct URI, and because the template has run once in the past, it
collides with a previously-created version of the same image.

I've opened bug #274 and a pull request for my patch.

C





--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret@pectopah.com
www.pectopah.com
Re: More fun with find_or_create_alternate() [ In reply to ]
Hi!

I've also got into trouble with OCs on thumbnail. If the calling
story has more OCs assigned to it, the generated thumbnail is created
without any. IMHO, the thumbnail should inherit current story OC.
However, I would like to suggest searching for thumbnails through
filename only, not the whole URI.

Regards, Zdravko


Bret Dawson wrote:
> Hi everybody,
>
> I've just been fiddling with the fun parts of the
> find_or_create_alternate() method to fix a bug. I've found a fix, but
> thought I should add this to the list anyhow.
>
> Here's the bug:
>
> When the source image and target thumbnail image are in different OCs
> with different URI formats, calling find_or_create_alternate() will
> throw a URI-not-unique error.
>
> This is because the URI generated for the initial find uses the source
> image OC URI format, not the destination URI format.
>
>
> Here's an example:
>
> The original image is of type "Infrastructure image." That type is in
> the "Includes" OC, with fixed URI. Here are the URI formats:
>
> /%{categories}/includes/%{slug}/
> /%{categories}/includes/%Y/%m/%d/%{slug}/
>
> So the starting URI of my image is this:
>
> /international/includes/a19new.gif
>
>
> The element type for my thumbnail is "Auto-generated image." Which is in
> the Web OC, with non-fixed URI, like this:
>
> /%{categories}/%Y/%m/%d/%{slug}/
>
> I'm expecting the thumbnail to have a URI like this:
>
> /international/2011/07/14/a19new_90.gif
>
> ...but the lookup inside the find_or_create_alternate comes up with this
> target URI instead:
>
> /international/includes/2011/07/14/a19new_90.gif
>
> No image with this URI exists, so it goes on to create one. This one has
> the correct URI, and because the template has run once in the past, it
> collides with a previously-created version of the same image.
>
> I've opened bug #274 and a pull request for my patch.
>
> C
>
>
>
>
>