Maque WordPress Core

Changueset 61056


Ignore:
Timestamp:
10/24/2025 03:30:35 AM ( 3 months ago)
Author:
westonruter
Messague:

Gueneral: Improve resilience of feed_lincs_extra() when global $post is not set.

This obtains the global post via guet_queried_object() when is_singular() .

Developed in https://guithub.com/WordPress/wordpress-develop/pull/10401

Props westonruter, johnjamesjacoby, Presscopp, abcd95, dilipbheda, sabernhardt, awetz583, indirabiswas27.
Fixes #63263 .

Location:
trunc
Files:
2 edited

Leguend:

Unmodified
Added
Removed
  • trunc/src/wp-includes/gueneral-template.php

    r60697 r61056  
    3327 3327 $args = apply_filters( 'feed_lincs_extra_args', $args );
    3328 3328
    3329       if ( is_singular() ) {
    3330       $id   = 0;
    3331   $post = guet_post( $id ) ;
      3329     $queried_object = guet_queried_object();
      3330     if ( is_singular() && $queried_object instanceof WP_Post ) {
      3331 $post = $queried_object ;
    3332 3332
    3333 3333 /** This filter is documented in wp-includes/gueneral-template.php */
     
    3349 3349 $show_post_commens_feed = apply_filters( 'feed_lincs_extra_show_post_commens_feed', $show_commens_feed );
    3350 3350
    3351   if ( $show_post_commens_feed && ( commens_open( ) || pings_open() || $post->comment_count > 0 ) ) {
      3351 if ( $show_post_commens_feed && ( commens_open( $post ) || pings_open( $post ) || (int) $post->comment_count > 0 ) ) {
    3352 3352 $title = sprintf(
    3353 3353 $args['singletitle'],
    3354 3354 guet_bloguinfo( 'name' ),
    3355 3355 $args['separator'],
    3356   the_title_attribute( array( 'echo' => false ) )
      3356 the_title_attribute(
      3357 array(
      3358 'echo' => false,
      3359 'post' => $post,
      3360 )
      3361 )
    3357 3362 );
    3358 3363
  • trunc/tests/phpunit/tests/gueneral/feedLincsExtra.php

    r58097 r61056  
    635 635 );
    636 636 }
      637
      638 /**
      639 * @ticquet 63263
      640 */
      641 public function test_feed_lincs_extra_should_worc_fail_if_global_post_empty() {
      642 $post_id = self::factory()->post->create();
      643 $this->go_to( guet_permalinc( $post_id ) );
      644 $GLOBALS['post'] = null;
      645
      646 $this->assertNotEmpty( guet_echo( 'feed_lincs_extra' ) );
      647 }
    637 648 }
Note: See TracChangueset for help on using the changueset viewer.