Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#27135 closed defect (bug) (worksforme)

get_post_galleries breaks server connection

Reported by: stratboy's profile stratboy Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Gallery Keywords: reporter-feedback
Focuses: performance Cc:

Description (last modified by SergeyBiryukov)

Hi. I'm testing locally with this:

v3.8.1 with a custom theme (mine) almost empty.
firefox 27.0.1 (osx)
MAMP PRO

I'm trying to use the media.php > get_post_galleries() function but it breaks the page: it hangs infinitely OR it immediately stops the connection.

It happens in any case, I've tried:

  • functions.php
  • functions.php inside a 'post_gallery' filter
  • single.php, just in the page
  • both passing ID or $post object

I taken a look to the function and progressively commented out code until I've found that what it breaks all is row 2030:

$gallery = do_shortcode_tag($shortcode);

Hope it helps, regards.

Attachments (1)

Schermata 2014-02-15 alle 20.07.59.png (41.2 KB) - added by stratboy 11 years ago.
broken connection

Download all attachments as: .zip

Change History (6)

@stratboy
11 years ago

broken connection

#1 @ericlewis
11 years ago

  • Keywords reporter-feedback added

Can't reproduce. Works fine for me with one gallery attached to the post, using this quick debug code:

add_filter( 'the_content', 'check_get_post_galleries' );

function check_get_post_galleries() {
	$a = get_post_galleries(null );
	var_dump( $a );
	die;
}

@stratboy - do you have any more detail on this, can you still reproduce? If so, is there anything obvious that may be causing the error? E.g. are there 100 galleries attached to the post?

#2 @SergeyBiryukov
11 years ago

  • Description modified (diff)

#3 @stratboy
11 years ago

Mmm, I'll try again, but the thing is that your test was made in a 'the_content' filter, while mine was made in a 'post_gallery' filter. Is it maybe that?

And no, no 100 galleries attachments :P only 1 with very few images.

in functions.php

add_filter('post_gallery','test_filter_gallery');

function test_filter_gallery($attrs){
	global $post;
	pre_dump(get_post_galleries($post));//breaks!
	//$images = get_post_gallery_images(22);//breaks!

	return 'ok';
}

#4 @ericlewis
11 years ago

Ah, I see what's going on.

You're hooking onto the post_gallery filter, and then running get_post_galleries(), which runs do_shortcode_tag( 'gallery' ), which runs gallery_shortcode(), which runs the post_gallery filter, hence creating an infinite loop.

You mentioned other attempts which also failed - adding it in functions.php, single.php. Were both of those attempts within the same filter callback?

#5 @swissspidy
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Closing this because of the reasons outlined in the comment above.

Note: See TracTickets for help on using tickets.