This is a valid RSS feed.
This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
</description>
<title>bbPress Trac</title>
^
</channel>
^
<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>bbPress Trac: Ticket #3588: Registered meta values for bbPress forum and topic post types not properly defined, causing problems with REST updates</title>
<link>https://bbpress.trac.wordpress.org/ticket/3588</link>
<description><p>
I've noticed in the <code>register_meta()</code> method in <code>bbpress.php</code>, there is a section that registers metadata for users and the custom post types that bbPress uses:
</p>
<div class="wiki-code"><div class="code"><pre><span class="x">// Define "count" meta-type array
$count = array(
// Counts are always integers
'type' =&gt; 'integer',
// Generic count description
'description' =&gt; esc_html__( 'bbPress Item Count', 'bbpress' ),
// Counts are single values
'single' =&gt; true,
// Counts should be made available in REST
'show_in_rest' =&gt; true,
// Never allow counts to go negative
'sanitize_callback' =&gt; 'bbp_number_not_negative',
// All users may update count meta data
'auth_callback' =&gt; '__return_true'
);
/** Post **************************************************************/
// Counts
register_meta( 'post', '_bbp_topic_count', $count );
register_meta( 'post', '_bbp_reply_count', $count );
register_meta( 'post', '_bbp_total_topic_count', $count );
register_meta( 'post', '_bbp_total_reply_count', $count );
register_meta( 'post', '_bbp_voice_count', $count );
register_meta( 'post', '_bbp_anonymous_reply_count', $count );
register_meta( 'post', '_bbp_topic_count_hidden', $count );
register_meta( 'post', '_bbp_reply_count_hidden', $count );
register_meta( 'post', '_bbp_forum_subforum_count', $count );
</span></pre></div></div><p>
This is all fine and dandy, but these meta registrations do not define an <code>object_subtype</code>, i.e. they are not tied to a particular post type, and are registered for all standard and custom posts.
</p>
<p>
Usually, this doesn't create any issue, since you don't have to register metadata to use them. But if you were to retrieve the metadata of any post in REST, the data will always be included with the post's metadata, regardless of whether the post is actually a bbPress Forum / Topic or not.
</p>
<pre class="wiki">// When retrieving post data from WordPress's Gutenberg framework,
// the bbPress meta keys will always be included, even for standard post types.
const meta = wp.data.select('core/editor').getEditedPostAttribute('meta');
</pre><p>
Clearly, this is an inconvenience because you will then have to strip the meta values of these unrelated bbPress meta values before you save them.
</p>
<p>
The fix is simple! Just attach a post type to all registered post meta!
</p>
<div class="wiki-code"><div class="code"><pre><span class="cp">&lt;?php</span>
<span class="sd">/** Post **************************************************************/</span>
<span class="nv">$forum</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$count</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">'object_subtype'</span> <span class="o">=&gt;</span> <span class="s1">'forum'</span><span class="p">));</span>
<span class="nv">$topic</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$count</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">'object_subtype'</span> <span class="o">=&gt;</span> <span class="s1">'topic'</span><span class="p">));</span>
<span class="c1">// Counts
</span><span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_topic_count'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_reply_count'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_reply_count'</span><span class="p">,</span> <span class="nv">$topic</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_total_topic_count'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_total_reply_count'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_voice_count'</span><span class="p">,</span> <span class="nv">$topic</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_anonymous_reply_count'</span><span class="p">,</span> <span class="nv">$topic</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_topic_count_hidden'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_reply_count_hidden'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_reply_count_hidden'</span><span class="p">,</span> <span class="nv">$topic</span> <span class="p">);</span>
<span class="nx">register_meta</span><span class="p">(</span> <span class="s1">'post'</span><span class="p">,</span> <span class="s1">'_bbp_forum_subforum_count'</span><span class="p">,</span> <span class="nv">$forum</span> <span class="p">);</span>
</pre></div></div><p>
I've deployed the fix in a pull request. I hope this gets implemented soon! It is annoying to deal with.
</p>
</description>
<language>en-us</language>
<image>
<title>bbPress Trac</title>
<url>https://bbpress.trac.wordpress.org/chrome/site/your_project_logo.png</url>
<link>https://bbpress.trac.wordpress.org/ticket/3588</link>
</image>
<generator>Trac 1.2.2</generator>
<item>
<dc:creator>r-a-y</dc:creator>
<pubDate>Thu, 30 Nov 2023 22:41:54 GMT</pubDate>
<title>status changed; resolution set; milestone deleted</title>
<link>https://bbpress.trac.wordpress.org/ticket/3588#comment:1</link>
<guid isPermaLink="false">https://bbpress.trac.wordpress.org/ticket/3588#comment:1</guid>
<description>
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
<li><strong>milestone</strong>
<em>Awaiting Review</em> deleted
</li>
</ul>
<p>
Hi terresquall, I have an open ticket about this. See <a class="new ticket" href="https://bbpress.trac.wordpress.org/ticket/3436" title="#3436: defect (bug): register_meta() calls should use 'object_subtype' argument (new)">#3436</a>.
</p>
<p>
Feel free to attach a new patch if the ones I have there do not fix your problem.
</p>
</description>
<category>Ticket</category>
</item>
</channel>
</rss>
If you would like to create a banner that links to this page (i.e. this validation result), do the following:
Download the "valid RSS" banner.
Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)
Add this HTML to your page (change the image src
attribute if necessary):
If you would like to create a text link instead, here is the URL you can use: