WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
[resolved] Suggestion to include rewrite.php for ajax requests (2 posts)

  1. barkgj
    Member
    Posted 2 years ago #

    We are creating a theme that allows front-end dragging and dropping of portions of the screen. Our theme relies on AJAX calls that (re)render portions of the screen to get an 'ultimate' user experience. Ofcourse each AJAX call automatically 'DEFINES' the DOING_AJAX.

    It appears when the theme re-rendering a portion of the screen that contains a nggallery shortcode, the webservice throws a 500 error;

    -------- error log

    PHP Fatal error: Call to a member function get_permalink() on a non-object in /var/www/html/wp-content/plugins/nextgen-gallery/nggfunctions.php on line 289

    -------- line 289 of nggfunctions:

    $gallery->slideshow_link = $nggRewrite->get_permalink(array ( 'show' => 'slide') );

    -------

    When inspecting the NextGen code I see this is NOT a bug in the code; it appears the rewrite.php is intentionally left out for optimization reasons;

    -------- (line 336 of nggalery.php)

    // We didn't need all stuff during a AJAX operation
    if ( defined('DOING_AJAX') )
    require_once (dirname (__FILE__) . '/admin/ajax.php');
    else
    {
    // include other files among which rewrite.php

    --------

    It appears including the rewrite.php file would fix our problem:

    // We didn't need all stuff during a AJAX operation
    if ( defined('DOING_AJAX') )
    {
    require_once (dirname (__FILE__) . '/admin/ajax.php');
    require_once (dirname (__FILE__) . '/lib/rewrite.php'); // 71.936 <--- adding this line helps us out
    }
    else
    {
    ... no modifications here
    }

    Here's a screen recording I made to show you what we try to accomplish (here I patched the file)

    http://screencast.com/t/apOZvBuvxl

    ------

    Any suggestion would be welcome :)
    Thanks

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. barkgj
    Member
    Posted 2 years ago #

    I concluded myself there could be several directions to solve this problem:

    a) requesting NextGen to _do_ inject the redirect.php file. I concluded this would not be ideal; other users would be 'punished' with more heavy memory load even though for them this would not add any benefits. I also concluded this solution would not help our theme in a proper way as other plugins might use the same optimization techniques so I would have to repeat these steps for each other plugin working the same way.

    b) forking NextGen and adding the redirect.php. I condluded this would also not be ideal; each time a new version of NextGen is released we would have to make another release of the fork too. Would be too time consuming. Also this approach would require end users to have to perform actions to 'solve' this problem, which is not very user friendly.

    c) inkecting a non-standard webservice implementation in our WP theme that does a 1:1 copy of the "original" WP webservice implementation, without defining the DOING_AJAX. This sounds like the best approach; end users don't have to do a thing to have NextGen work using our theme, and NextGen doesn't have to adjust anything.

    Closing the task :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic