get_object_fallback needs to be redirect-aware

VERIFIED FIXED in 2.4.3

Status

P1
normal
VERIFIED FIXED
8 years ago
8 years ago

People

(Reporter: jsocol, Assigned: erik)

Tracking

unspecified
2.4.3

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
(I know this makes get_object_fallback particularly complex. I'll file a CQ bug to address that next.)

In get_object_fallback, we need an extra case, essentially in here:

> if hasattr(fallback, 'translated_to'):
>     trans = fallback.translated_to(locale)
>     if trans and trans.current_revision:
>         return trans
> --> RIGHT HERE

We need to check fallback.content to see if it's a redirect, and if so, check that the target article has been localized. In pseudocode:

if fallback.content.startswith('REDIRECT'):
    target = get_redirect_target(fallback.content)
    if target.exists()
        trans = target.translated_to(locale)
        if trans and trans.current_revision:
            return trans

I don't think we should return target if the trans doesn't exist, but I'm open to arguments for or against that.
(Reporter)

Updated

8 years ago
Blocks: 627360
(Assignee)

Comment 1

8 years ago
The test for whether the doc is a redirect belongs in the Document model. Perhaps Document.redirect_url() suffices; perhaps not.
(Reporter)

Comment 2

8 years ago
That sounds like volunteering => Erik.

I agree that this belongs on the model, but it shouldn't require schema changes.
Assignee: nobody → erik
(Assignee)

Comment 3

8 years ago
Landed in http://github.com/jsocol/kitsune/commit/fe593fb.
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
Please add QA steps or [qa-], thanks
(Assignee)

Comment 5

8 years ago
From the commit message: "This means that, for example, if you have Document D in Deutsch which links to [[A]], A is a redirect to B, and B has a Deutsch translation Bd, rendering D will give you a link straight to Bd. That's about as simple as it gets, I'm afraid, but it's really handy when English articles get renamed and tranlations linked straight to the English."
Took me a while, but I verified this. Sorry I missed the checkin notes.
Status: RESOLVED → VERIFIED
(Reporter)

Updated

8 years ago
Duplicate of this bug: 618270
(Reporter)

Updated

8 years ago
Duplicate of this bug: 618270
You need to log in before you can comment on or make changes to this bug.