Possible bug in geodir_listing_permalink_structure()

This topic contains 8 replies, has 3 voices, and was last updated by  Jeff 9 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #25293

    Jeff
    Buyer
    Post count: 188

    This could be my bug, but I’m confused about what’s happening.

    I have a client using my GT Vouchers plugin and in one of the widgets, I show the most recent vouchers and link to them. On his site, the links come back NULL when I call get_post_permalink( $voucher_post->ID );

    I traced this and get_post_permalink runs your filter geodir_listing_permalink_structure and this is where the NULL comes from. My link is passed in, the post information is there etc. The code I don’t quite get is this (line 1028) but I cleaned it up to post here:

    
    
    	if ( isset( $post_obj->ID ) && isset( $post->ID ) && $post_obj->ID == $post->ID ) {
    	} elseif ( isset( $post_obj->post_status ) && $post_obj->post_status == 'auto-draft' ) {
    		return $post_link;
    	} else {
    		$orig_post = $post;
    		$post      = $post_obj;
    	}

    I’ve debugged this and we’re hitting the third condition – the ELSE. My $post_obj coming in has an ID of 321, but the current post – for some reason – is 128, the don’t match and so the posts get swapped. Which is fine, but confusing.

    Then we get to 1054:

    
    
    		if ( isset( $gd_permalink_cache[ $post->ID ] ) && $gd_permalink_cache[ $post->ID ] ) {
    			if ( isset( $orig_post ) ) {
    				$post = $orig_post;
    			}
    
    			return $gd_permalink_cache[ $post->ID ];
    		}

    The code checks if the cache exists for $post->ID (which is 321 coming from my $post_obj) and if it is set checks if we have an $orig_post and then returns THAT link instead, which is obviously not going to be the link that I asked for.

    Any thoughts on WHY this is and how I should handle this? Maybe because I am in a widget and don’t setup the full global $post object? but I’m not sure why GeoDirectory is overriding that…

    #25305

    Paolo
    Site Admin
    Post count: 31206

    Hi Jeff,

    I’ve flagged this for Stiofan.

    Thx

    #26328

    Jeff
    Buyer
    Post count: 188

    Can I get an update on this bug? My client is still having issues. I can share site details if you need.

    #26409

    Paolo
    Site Admin
    Post count: 31206

    Sorry Jeff,

    I think Stiofan missed it. I’ve added it to Project Manager and sent him a reminder via email too.

    Thanks for your patience,

    #26723

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Jeff, I have made a few changes to that function, can u give me steps on how to replicate this or do u want me to send u the updated functions to see if it is still a problem?

    Stiofan

    #26800

    Jeff
    Buyer
    Post count: 188

    Thanks for looking at it Stiofan.

    If you can email me the code, that might be best. I can’t reproduce it on my own site/server so I would need to do it on the client site directly.

    #26848

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Jeff,

    Please find the file attached.

    Thanks,

    Stiofan

    #26939

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Yes Jeff there was a bug in our code, i have just fixed it and it will be in the next ver, it was in that function and we were setting the original post object back and then asking for the ID which ofcourse will be the wrong one.

    u can fix by changing this line

    if(isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample){$post_id = $post->ID; if(isset($orig_post)){$post = $orig_post;} return $gd_permalink_cache[$post_id];}

    Thanks,

    Stiofan

    #27059

    Jeff
    Buyer
    Post count: 188

    Thanks Stiofan:

    The last bit of code seems to solve the issue. The file you sent doesn’t contain this fix, but does have several other changes. Just making sure you’re aware.

Viewing 9 posts - 1 through 9 (of 9 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket