• Hi!

    A lot of Polylang users report a conflict with Nextgen Gallery. When trying to access their gallery, they are redirected to the album page.

    If I try to access /albums/nggallery/my_album/my_gallery
    I am redirected to /albums

    Spending some hours to debug this, I concluded that Polylang is making a redirection based on a wrong information.

    Polylang has a canonical redirection mechanism. But It receives //albums in $_SERVER['REQUEST_URI'] (wrong as I am expecting /albums/nggallery/my_album/my_gallery and worse, malformed due to the two slashes).
    Thus passing this value to the WordPress core function redirect_canonical, it logically returns /albums, different from the requested url known by Polylang, which thus fires the redirection to the wrong url.

    https://www.ads-software.com/plugins/nextgen-gallery/

Viewing 10 replies - 16 through 25 (of 25 total)
  • Hi,

    found solution. The needed change needed is in the plugin Polylang.

    in polylang/frontend/frontend-links.php change

    add_action('wp', array(&$this, 'check_canonical_url'), 10, 0); // before WordPress redirect_canonical, avoid passing the WP object

    to

    add_action('wp', array(&$this, 'template_redirect'), 10, 0); // before WordPress redirect_canonical, avoid passing the WP object

    This works on PolyLang 1.7.6 and NextGEN 2.1.0.

    Thread Starter Chouby

    (@chouby)

    @mjakop
    What you do is wrong and will break something.

    As far as I have tested on my website everything still works after this change.

    @mjakop, this is what those changes do for me: https://img.ctrlv.in/img/15/07/06/559a833bd0e98.png

    Don’t know where you took that from but template_redirect is not in PLL_Frontend_Links model.

    P.S. If you follow the link to gallery in albums, result is: “no images found”. What I do is set: $redirect_url = $requested_url;

    To skip this check:

    if ($do_redirect && $redirect_url && $requested_url != $redirect_url) {
    			wp_redirect($redirect_url, 301);
    			exit;
    		}

    its not global so no harm done, unless the $requested_url doesnt exist anymore for real.

    P.S. In my optinion 404 would be better instead of 301, or at least 303. If language doesn’t exist then redirect to something that exists (Something with no language or default one, should surely exist, it 100% more valid to look at some information, than to and information that makes you stressed). If wordpress data wasn’t serialised I would suggest looking up slug with LIKE %first_4_letter_of_slug%, but now, I know not how to do it with serialised data. ?? Thanks for attention ??

    Plugin Contributor photocrati

    (@photocrati)

    @mjakop – Thanks for sharing.

    – Cais.

    Sorry, is there a fix for this issue?

    Plugin Contributor photocrati

    (@photocrati)

    @informatique – Please start your own topic so we can try to help you with your specific issue on your specific site.

    See https://codex.www.ads-software.com/Forum_Welcome#Where_To_Post

    Thanks!

    – Cais.

    Hi,

    found solution. The needed change needed is in the plugin Polylang.

    in polylang/frontend/frontend-links.php change

    This solution don’t work for me.
    But in this file i found function called check_canonical_url and add:

    if ( is_page_template('page-gallery.php')) {
    			return;
    		}

    for page where I’m using NextGen Gallery.

    Thread Starter Chouby

    (@chouby)

    Yes there are ways to hack Polylang to work around the NextGen Gallery bug putting two slashes in urls (these 2 slashes cause the redirection by Polylang as it is detected as a wrong url).

    Another user of both plugins digged into NextGen Gallery code (I didn’t) and it seems that he found the source of the second slash. See:
    https://www.ads-software.com/support/topic/clicking-slideshow-opens-homepage?replies=23#post-7555706

    Plugin Contributor photocrati

    (@photocrati)

    @chouby – If you are still having these issues please contact us directly so we can help you work through the issues you continue to see.

    Try either of these pages:
    https://nextgen-gallery.com/contact/
    https://nextgen-gallery.com/report-bug/

    Thanks!

    – Cais.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Why hacking $_SERVER['REQUEST_URI']?’ is closed to new replies.