Skip to:
Content

bbPress.org

Opened 7 years ago

Closed 7 weeks ago

#3362 closed defect (bug) (fixed)

Admin area updates delete subscriptions on posts.

Reported by: wpturk Owned by: johnjamesjacoby
Priority: highest omg sweet tea Milestone: 2.6.20
Component: General - Administration Version:
Severity: major Keywords:
Cc:

Description (last modified by johnjamesjacoby)

I am running the latest 2.6.4 and discovered problem regarding subscriptions:

This is before updating topic (post_id:60483) in admin area:

mysql> select * from forum_postmeta where meta_key="_bbp_subscription" and post_id="60483" ;
+---------+---------+-------------------+------------+
| meta_id | post_id | meta_key          | meta_value |
+---------+---------+-------------------+------------+
|   61987 |   60483 | _bbp_subscription | 4811       |
+---------+---------+-------------------+------------+
1 row in set (0.00 sec)

This is after updating the topic (post_id:60483) in admin area:

mysql> select * from forum_postmeta where meta_key="_bbp_subscription" and post_id="60483" ;
Empty set (0.00 sec)

The subscription is DELETED after admin changes something and updates a post.

Change History (8)

#1 @wpturk
7 years ago

Ok it took me a few hours but I found what is deleting the subscription:

Line 811 in bbpress/includes/topics/functions.php (if I comment this line it works fine)

                // Check if subscribed
                $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );

                // Check for action
                $subscheck  = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) )
                        ? true
                        : false;

                // Subscribed and unsubscribing
                if ( ( true === $subscribed ) && ( false === $subscheck ) ) {
                        bbp_remove_user_subscription( $author_id, $topic_id );

During backend update there will be no checkbox selected and $subscheck is false and bbp_remove_user_subscription is executed. This explains also why only author subscription is deleted not other subscribers.

#2 @wpturk
7 years ago

the same issue for replies: bbpress/includes/replies/functions.php

#3 @johnjamesjacoby
6 years ago

  • Component General → General - Administration
  • Milestone Awaiting Review → 2.6.7
  • Owner set to johnjamesjacoby
  • Status new → accepted

#4 @johnjamesjacoby
6 years ago

  • Milestone 2.6.7 → Under Consideration

Hey @wpturk, sorry for the delay in looking into this.

Unfortunately, I'm unable to replicate this under normal conditions, and I could use a bit more information from you. Is it possible to detail exactly what steps need to be taken to force this to happen?

I've swapped between two Keymaster users, subscribed to two separate topics, and editing either topic from within WordPress Admin does not remove subscriptions from either, regardless of the user and their subscription status.

I was able to force it by de-registering the bbp_topic_subscriptions_metabox meta-box and then editing a topic I was subscribed to. That forces it because the "bbp_topic_subscription" input ends up not being output, failing the subcheck but passing as subscribed. This behavior is unintended, but definitely an edge-case. It's worth fixing, but likely not in a minor release.

Any ideas or help you can offer is welcome and greatly appreciated. 🙏

#5 @wpturk
6 years ago

Hi John,

Thanks looking on this.

I swapped to the default wp theme and deactivated plugins, the same problem occurs there too. The topic author subscription gets deleted on post saving in backend.

When I print all $POST variables on save_post hook, bbp_topic_subscription returns empty.

<?php
...
    [_thumbnail_id] => -1
    [page] => 0
    [paged] => 1
    [bbp_topic_subscription] => 
    [post_name] => paypal-devri-turkiyede-kapaniyor-mu
    [icl_make_translatable] => topic,0
    [_icl_nonce_imi] => 3658332707
    [post_mime_type] => 
    [ID] => 283
...

Sorry, I have no idea why bbp_topic_subscriptions_metabox is not delivering the subscriptions.

#6 @johnjamesjacoby
7 weeks ago

  • Description modified (diff)
  • Milestone Under Consideration → 2.6.20

#7 @johnjamesjacoby
7 weeks ago

In 7765:

Subscriptions: Preserve subscriptions on admin edits.

Move topic-subscription handling out of the generic topic and reply update functions and into the front-end form actions. This prevents WordPress admin edits and programmatic updates from changing an author's subscription without an explicit form choice.

Remove the obsolete hidden admin metabox field and add regression coverage for topic and reply saves.

In trunk, for 2.7.

Props wpturk.
See #3362.

#8 @johnjamesjacoby
7 weeks ago

  • Resolution → fixed
  • Status accepted → closed

In 7766:

Subscriptions: Preserve subscriptions on admin edits.

Move topic-subscription handling out of the generic topic and reply update functions and into the front-end form actions. This prevents WordPress admin edits and programmatic updates from changing an author's subscription without an explicit form choice.

Remove the obsolete hidden admin metabox field and add regression coverage for topic and reply saves.

In branches/2.6, for 2.6.20.

Props wpturk.
Fixes #3362.

Note: See TracTickets for help on using tickets.