Ticket #1261: local.diff

File local.diff, 13.6 KB (added by chrishajer, 2 years ago)

Here's a svn diff of my local installation after applying 1261-method2.diff

  • bb-templates/kakumei/rss2.php

     
    66<rss version="2.0" 
    77       xmlns:content="http://purl.org/rss/1.0/modules/content/" 
    88       xmlns:dc="http://purl.org/dc/elements/1.1/" 
    9        xmlns:atom="http://www.w3.org/2005/Atom"> 
     9       xmlns:atom="http://www.w3.org/2005/Atom" 
     10       <?php do_action( 'bb_rss2_ns'); ?> 
     11       > 
    1012       <channel> 
    1113               <title><?php echo $title; ?></title> 
    1214               <link><?php echo $link; ?></link> 
    13                <description><![CDATA[<?php echo $description; ?>]]></description> 
    14                <language><?php esc_html( bb_option('language') ); ?></language> 
    15                <pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate> 
     15               <description><?php echo $description; ?></description> 
     16               <language><?php echo esc_html( bb_get_option( 'language' ) ); ?></language> 
     17               <pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate> 
    1618               <?php bb_generator( 'rss2' ); ?> 
    17                <textInput> 
    18                        <title><![CDATA[<?php _e('Search'); ?>]]></title> 
    19                        <description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description> 
    20                        <name>q</name> 
    21                        <link><?php bb_uri('search.php'); ?></link> 
    22                </textInput> 
     19               <?php do_action( 'bb_rss2_head' ); ?> 
    2320               <atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" /> 
    2421 
    25 <?php foreach ($posts as $bb_post) : ?> 
     22<?php foreach ( (array) $posts as $bb_post ) : ?> 
    2623               <item> 
    27                        <title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title> 
     24                       <title><?php post_author(); ?> <?php _e( 'on' ); ?> "<?php topic_title( $bb_post->topic_id ); ?>"</title> 
    2825                       <link><?php post_link(); ?></link> 
    29                        <pubDate><?php bb_post_time('D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate> 
     26                       <pubDate><?php bb_post_time( 'D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate> 
    3027                       <dc:creator><?php post_author(); ?></dc:creator> 
    3128                       <guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid> 
    32                        <description><?php post_text(); ?></description> 
     29                       <description><?php post_text_rss(); ?></description> 
     30                       <content:encoded><![CDATA[<?php post_text_rss(); ?>]]></content:encoded> 
     31                       <?php do_action( 'bb_rss2_item' ); ?> 
    3332               </item> 
    3433<?php endforeach; ?> 
    3534 
  • bb-includes/defaults.bb-filters.php

     
    115115function bb_filter_feed_content() 
    116116{ 
    117117       if ( bb_is_feed() ) { 
    118                add_filter( 'bb_title_rss', 'ent2ncr' ); 
    119                add_filter( 'topic_title', 'ent2ncr' ); 
     118               add_filter( 'bb_title_rss', 'strip_tags' ); 
     119               add_filter( 'bb_title_rss', 'ent2ncr', 8 ); 
     120               add_filter( 'bb_title_rss', 'esc_html' ); 
     121 
     122               add_filter( 'bb_description_rss', 'strip_tags' ); 
     123               add_filter( 'bb_description_rss', 'ent2ncr', 8 ); 
     124               add_filter( 'bb_description_rss', 'esc_html' ); 
     125 
     126               add_filter( 'post_author', 'ent2ncr', 8 ); 
    120127               add_filter( 'post_link', 'esc_html' ); 
    121                add_filter( 'post_text', 'htmlspecialchars' ); // encode_bad should not be overruled by esc_html 
    122                add_filter( 'post_text', 'ent2ncr' ); 
     128               add_filter( 'post_text_rss', 'ent2ncr', 8 ); 
     129               add_filter( 'post_text_rss', 'esc_html' ); 
    123130       } 
    124131} 
    125132add_action( 'bb_init', 'bb_filter_feed_content' ); 
  • bb-includes/functions.bb-template.php

     
    17851785       } 
    17861786} 
    17871787 
     1788function post_text_rss( $post_id = 0 ) { 
     1789       echo apply_filters( 'post_text_rss', get_post_text( $post_id ), get_post_id( $post_id ) ); 
     1790} 
     1791 
    17881792function post_text( $post_id = 0 ) { 
    17891793       echo apply_filters( 'post_text', get_post_text( $post_id ), get_post_id( $post_id ) ); 
    17901794} 
  • rss.php

     
    7373                               die(); 
    7474 
    7575                       $topics = $topics_object->results; 
    76                        if ( !$topics || !is_array($topics) ) 
    77                                die(); 
    7876 
    7977                       $posts = array(); 
    80                        foreach ($topics as $topic) { 
     78                       foreach ( (array) $topics as $topic ) { 
    8179                               $posts[] = bb_get_first_post($topic->topic_id); 
    8280                       } 
    8381 
    84                        $title = esc_html( sprintf( __( '%1$s &raquo; View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] ) ); 
     82                       $title = sprintf( __( '%1$s &raquo; View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] ); 
    8583                       $link = get_view_link($feed_id); 
    8684                       $link_self = bb_get_view_rss_link($feed_id); 
    8785                       break; 
     
    9088                       if ( !$topic = get_topic ( $feed_id ) ) 
    9189                               die(); 
    9290                       if ( !$posts = get_thread( $feed_id, 0, 1 ) ) 
    93                                die(); 
    94                        $title = esc_html( sprintf( __( '%1$s &raquo; Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() ) ); 
     91                               die(); /* Should die here, as the topic posts aren't there, so the topic is most probably deleted/empty */ 
     92                       $title = sprintf( __( '%1$s &raquo; Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() ); 
    9593                       $link = get_topic_link($feed_id); 
    9694                       $link_self = get_topic_rss_link($feed_id); 
    9795                       break; 
    9896 
    9997               case 'profile': 
    100                        if ( bb_get_option( 'mod_rewrite' ) === 'slugs' ) { 
    101                                $user = bb_get_user_by_nicename( $feed_id ); 
     98                       if ( bb_get_option( 'mod_rewrite' ) === 'slugs') { 
     99                               if ( !$user = bb_get_user_by_nicename( $feed_id ) ) 
     100                                       $user = bb_get_user( $feed_id ); 
    102101                       } else { 
    103                                $user = bb_get_user( $feed_id ); 
     102                               if ( !$user = bb_get_user( $feed_id ) ) 
     103                                       $user = bb_get_user_by_nicename( $feed_id ); 
    104104                       } 
    105105                       if ( !$user ) { 
    106106                               die(); 
    107107                       } 
    108                        if ( !$posts = get_user_favorites( $user->ID ) ) { 
    109                                die(); 
    110                        } 
    111                        $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ) ); 
    112                        $link = bb_get_profile_link($feed_id); 
     108                       $posts = get_user_favorites( $user->ID ); 
     109 
     110                       $title = sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ); 
     111                       $link = get_user_profile_link($feed_id); 
    113112                       $link_self = get_favorites_rss_link($feed_id); 
    114113                       break; 
    115114 
    116115               case 'tag-topics': 
    117116                       if ( !$tag = bb_get_tag( $feed_id ) ) 
    118117                               die(); 
    119                        if ( !$topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) ) 
    120                                die(); 
     118                       $topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ); 
    121119 
    122120                       $posts = array(); 
    123                        foreach ($topics as $topic) { 
     121                       foreach ( (array) $topics as $topic ) { 
    124122                               $posts[] = bb_get_first_post($topic->topic_id); 
    125123                       } 
    126124 
    127                        $title = esc_html( sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() ) ); 
     125                       $title = sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() ); 
    128126                       $link = bb_get_tag_link($feed_id); 
    129127                       $link_self = bb_get_tag_topics_rss_link($feed_id); 
    130128                       break; 
     
    132130               case 'tag-posts': 
    133131                       if ( !$tag = bb_get_tag( $feed_id ) ) 
    134132                               die(); 
    135                        if ( !$posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) ) 
    136                                die(); 
    137                        $title = esc_html( sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() ) ); 
     133                       $posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ); 
     134                       $title = sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() ); 
    138135                       $link = bb_get_tag_link($feed_id); 
    139136                       $link_self = bb_get_tag_posts_rss_link($feed_id); 
    140137                       break; 
    141138 
    142139               case 'forum-topics': 
    143                        if ( !$topics = get_latest_topics( $feed_id ) ) 
    144                                die(); 
     140                       $topics = get_latest_topics( $feed_id ); 
    145141 
    146142                       $posts = array(); 
    147                        foreach ($topics as $topic) { 
     143                       foreach ( (array) $topics as $topic) { 
    148144                               $posts[] = bb_get_first_post($topic->topic_id); 
    149145                       } 
    150146 
    151                        $title = esc_html( sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ) ); 
     147                       $title = sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ); 
    152148                       $link = get_forum_link($feed_id); 
    153149                       $link_self = bb_get_forum_topics_rss_link($feed_id); 
    154150                       break; 
    155151 
    156152               case 'forum-posts': 
    157                        if ( !$posts = bb_get_latest_forum_posts( $feed_id ) ) 
    158                                die(); 
    159                        $title = esc_html( sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ) ); 
     153                       $posts = bb_get_latest_forum_posts( $feed_id ); 
     154                       $title = sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ); 
    160155                       $link = get_forum_link($feed_id); 
    161156                       $link_self = bb_get_forum_posts_rss_link($feed_id); 
    162157                       break; 
    163158 
    164159               // Get just the first post from the latest topics 
    165160               case 'all-topics': 
    166                        if ( !$topics = get_latest_topics() ) 
    167                                die(); 
     161                       $topics = get_latest_topics(); 
    168162 
    169163                       $posts = array(); 
    170                        foreach ($topics as $topic) { 
     164                       foreach ( (array) $topics as $topic ) { 
    171165                               $posts[] = bb_get_first_post($topic->topic_id); 
    172166                       } 
    173167 
    174                        $title = esc_html( sprintf( __( '%1$s &raquo; Recent Topics' ), bb_get_option( 'name' ) ) ); 
     168                       $title = sprintf( __( '%1$s &raquo; Recent Topics' ), bb_get_option( 'name' ) ); 
    175169                       $link = bb_get_uri(); 
    176170                       $link_self = bb_get_topics_rss_link(); 
    177171                       break; 
     
    179173               // Get latest posts by default 
    180174               case 'all-posts': 
    181175               default: 
    182                        if ( !$posts = bb_get_latest_posts( 35 ) ) 
    183                                die(); 
    184                        $title = esc_html( sprintf( __( '%1$s &raquo; Recent Posts' ), bb_get_option( 'name' ) ) ); 
     176                       $posts = bb_get_latest_posts( 35 ); 
     177                       $title = sprintf( __( '%1$s &raquo; Recent Posts' ), bb_get_option( 'name' ) ); 
    185178                       $link = bb_get_uri(); 
    186179                       $link_self = bb_get_posts_rss_link(); 
    187180                       break; 
    188181       } 
    189182} 
    190183 
    191 bb_send_304( $posts[0]->post_time ); 
     184if ( !$posts ) /* We do typecasting in the template, but all themes don't have that! */ 
     185       $posts = array(); 
     186else /* Only send 304 if there are posts */ 
     187       bb_send_304( $posts[0]->post_time ); 
    192188 
    193 if (!$description = esc_html( bb_get_option('description') )) { 
     189if (!$description = bb_get_option( 'description' ) ) { 
    194190       $description = $title; 
    195191} 
    196192$title = apply_filters( 'bb_title_rss', $title, $feed );