Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible WP v4 + bbPress + s2Member Conflict? #321

Closed
jaswrks opened this issue Sep 5, 2014 · 15 comments
Closed

Possible WP v4 + bbPress + s2Member Conflict? #321

jaswrks opened this issue Sep 5, 2014 · 15 comments

Comments

@jaswrks
Copy link
Contributor

jaswrks commented Sep 5, 2014

Referencing this topic at bbPress. http://bbpress.org/?p=151839

@MrsCog
Copy link

MrsCog commented Sep 5, 2014

Hi Jason,

I am running s2Member Pro and bbpress with the default twentyfourteen theme. All was well until the WP4.0 update. Now the text which creates and introduces each topic is missing (hidden from view) from the topic, but all the replies appear below as they should. The topic text and images still exist, I can see it from the admin panel, it is just invisible to the public. My bbpress forums are available for all to read whether logged in or not, but only Level 1 can leave replies or create topics. The (now hidden) topic text is missing for everyone whether they are logged in or not.

From what I understand from the bbpress support forum, others running bbpress are having variations of similar glitches when running any membership plugin and this conflict is not exclusive to S2member. I do not write code, nor am I proficient in modifications other than to plop a given string into a file, bestowed by a benevolent developer such as yourself lol. Any insights would be appreciated.

I did file a Tech Support ticket at WebSharks under the name Dagny with a link to my site. Great crew you have there. :-)

Thanks!

@johncockman
Copy link

S2Member is somehow removing the first post of all bbpress topics when Wordpress is upgraded to 4.0. Deactivating S2Member fixes the problem, but that is not really an option...

http://bluegrassdaddy.com/forums/

John

@philmeadows
Copy link

I suspect s2Member as the cause, sorry.

I replicated fault with vanilla install of WP4.0 + bbPress + s2Member, all with default settings. Create one forum with one topic, then navigate to the topic - you'll see the bb breadcrumbs and the leave a reply prompt, but no post content.

Then disable s2Member, revist the forum and viola! - the topic now displays!

@editor-mike
Copy link

I have this problem too.
The first topics are gone, we have found some code on-line that creates a temporary fix but the formatting is bad on the posts it has returned and all new posts have bad formatting.

It seems a common problem after the 4.0 upgrade and it also seems that disabling s2 works.
However this is not an option for us, please can anyone help?

Here is an example topic: http://www.thewargameswebsite.com/forums/topic/missing-posts/

@johncockman
Copy link

I have a fix for this: Go to the file named

content_single_topic.php

In the folder

bbpress/templates/default/bbpress

Put your cursor just before

             <?php if ( bbp_has_replies() ) : ?>

        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>

        <?php bbp_get_template_part( 'loop',       'replies' ); ?>

        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>

    <?php endif; ?>

Paste the following code:

<?php do_action( 'bbp_template_before_lead_topic' ); ?>
<ul id="bbp-topic-<?php bbp_topic_id(); ?>-lead" class="bbp-lead-topic">
<li class="bbp-header">
<div class="bbp-topic-author"><?php  _e( 'Creator',  'bbpress' ); ?></div><!-- .bbp-topic-author -->
<div class="bbp-topic-content">
<?php _e( 'Topic', 'bbpress' ); ?>
<?php bbp_topic_subscription_link(); ?>
<?php bbp_topic_favorite_link(); ?>
</div><!-- .bbp-topic-content -->
</li><!-- .bbp-header -->
<li class="bbp-body">
<div class="bbp-topic-header">
<div class="bbp-meta">
<span class="bbp-topic-post-date"><?php bbp_topic_post_date(); ?></span>
<a href="<?php bbp_topic_permalink(); ?>" class="bbp-topic-permalink">#<?php bbp_topic_id(); ?></a>
<?php do_action( 'bbp_theme_before_topic_admin_links' ); ?>
<?php bbp_topic_admin_links(); ?>
<?php do_action( 'bbp_theme_after_topic_admin_links' ); ?>
</div><!-- .bbp-meta -->
</div><!-- .bbp-topic-header -->
<div id="post-<?php bbp_topic_id(); ?>" <?php bbp_topic_class(); ?>>
<div class="bbp-topic-author">
<?php do_action( 'bbp_theme_before_topic_author_details' ); ?>
<?php bbp_topic_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?>
<?php if ( bbp_is_user_keymaster() ) : ?>
<?php do_action( 'bbp_theme_before_topic_author_admin_details' ); ?>
<div class="bbp-topic-ip"><?php bbp_author_ip( bbp_get_topic_id() ); ?></div>
<?php do_action( 'bbp_theme_after_topic_author_admin_details' ); ?>
<?php endif; ?>
<?php do_action( 'bbp_theme_after_topic_author_details' ); ?>
</div><!-- .bbp-topic-author -->
<div class="bbp-topic-content">
<?php do_action( 'bbp_theme_before_topic_content' ); ?>
<?php bbp_topic_content(); ?>
<?php do_action( 'bbp_theme_after_topic_content' ); ?>
</div><!-- .bbp-topic-content -->
</div><!-- #post-<?php bbp_topic_id(); ?> -->
</li><!-- .bbp-body -->

@editor-mike
Copy link

johncockman you are a lord.

@clavaque clavaque added bug and removed pro labels Sep 6, 2014
@philmeadows
Copy link

Johncockman, you Sir, win teh interwebs today!

@hnla
Copy link

hnla commented Sep 6, 2014

@johncockman That's not really a fix, more a dirty hack; proper investigation and debugging needs to happen before suggesting hacking a file in this manner, also you should advice people not to modify a core file but copy it to the theme to modify.

What you are circumventing is the single topic lead template part call which is wrapped in a conditional checking bbp_show_lead_topic() true/false for whatever reason this check is returning false when it ought to be true, why exactly remains to be seen but it's that that one needs to focus attention on.

@johncockman
Copy link

Apologies, hack not fix. Until a fix arrives, I am just happy to have my forum working normally.

@hnla
Copy link

hnla commented Sep 6, 2014

A better fix - on a copy of content-single-topic.php in a bbpress folder in the theme-

is to find the line:
<?php if ( bbp_show_lead_topic( ) ) : ?>

and change it to:
<?php if ( bbp_show_lead_topic( $show_lead = true ) ) : ?>

Even better than that is to write this as a filter run from functions.php probably until such time as a true reason and solution is provided.

This function run from a themes functions file ought to achieve same result:

function show_bbp_lead_topic_true() { $show_lead = true; return $show_lead; } add_filter('bbp_show_lead_topic', 'show_bbp_lead_topic_true');

@jaswrks jaswrks self-assigned this Sep 6, 2014
@jaswrks jaswrks added this to the Next Release milestone Sep 6, 2014
@jaswrks
Copy link
Contributor Author

jaswrks commented Sep 6, 2014

I'd like to thank everyone for their submissions here! They have been very helpful to those of us trying to investigate the issue in the source code of all three applications (i.e. WP, bbPress, s2). I really appreciate the assistance. Thanks!

My Research Indicates The Following Issues...

So far, I've been able to track this issue back to a change that occurred in WP v4.0, where it appears that the s query var (indicating a search query) in the WordPress core, is now treated a bit differently.

I'm referencing this line in the WP core that was changed in v4.0: http://bit.ly/1xpSGRp
The previous version of WordPress had this: http://bit.ly/1xpSYrF

In WordPress v4.0, I find the following fragment...

if ( isset( $this->query['s'] ) ) {
                $this->is_search = true;
            }

How is this change related to the conflict we see here?

bbPress sets the s key from bbp_has_replies() whether there is a search occurring or not (possibly a bug in bbPress). Therefore, the s flag isset(). This causes WP v4.0 to tell s2Member (and other plugins) that is_search() is TRUE, when actually it is not, in the case of bbPress. Referencing this line of code in bbPress: http://bit.ly/1xpTV2X

Ultimately, the fact that is_search() is TRUE on bbp_has_replies() (what I consider to be either a WP/bbPress bug), triggers s2Member's query filters that prevent protected content from being displayed in search results. It is these query filters in s2Member (and perhaps in other plugins like the Relevanssi search plugin) that are conflicting with the most recent versions of WP/bbPress. I'm not going to explain further than this, because it gets a bit convoluted :-) I'm really just pointing this out for the benefit of any other developers that visit this thread, hopefully to help me out here :-) Not all of this is the fault of s2Member. It will likely require a concerted effort to fully resolve this. In fact, it may turn out to be a WordPress core bug. I'm not entirely sure about this though, I need to look closer at the new isset() call in the core. It seems wrong to me at first glance.

Another Issue Found During this Investigation...

We are also looking at a potential conflict with _bbp_has_replies_where() around this line of code: http://bit.ly/1xpUr19 The issue here is that bbPress (under a default configuration) attempts to pull the lead topic post into the loop, but if s2Member has applied filters to the query (e.g. to exclude any protected replies) then bbPress bails, and the leading topic post is not displayed under a default configuration of bbPress. This will likely require a workaround in s2Member because it seems to be a core piece of functionality in bbPress that I don't expect to see changed anytime soon. Though, I think it's worth improving this in bbPress, to allow for filtered queries in a future release of bbPress.


Some Clarification Regarding bbp_show_lead_topic()

bbp_show_lead_topic() defaults to a value of FALSE. So unless you (or your theme) is filtering this internal option value in bbPress, the leading topic post is not displayed in this fashion. Instead, bbPress pulls the leading topic post into the list of replies. So there are two different functionality options within bbPress that we are dealing with here. One is to showcase the leading topic post (if your theme supports this), and the other is just to show it at the top, like any other reply in the list (default behavior).

If you filter bbp_show_lead_topic() and force it to a TRUE value (and your theme supports this), it will serve as a temporary workaround, as others have pointed out. It's important however, that you DO filter this value, and NOT just force a value of TRUE when you call the function; e.g. bbp_show_lead_topic(TRUE) may cause issues for you later. Why? Because once this issue is resolved and you upgrade, you could end up with two copies of the leading topic post in your list. I'd like to help you avoid this if at all possible.


Suggested Workaround (Temporarily)

Create the following directory and file:
/wp-content/mu-plugins/bbp-s2-fix.php

<?php
add_filter('bbp_show_lead_topic', '__return_true');

What's Next for s2Member?

In the short term, there are some steps that s2Member can take to help avoid a conflict. Now that we know what the issues are, we can work to tweak a few things here and there and push those changes out with the next release. I will post further updates soon. I'm also hoping to relay this information to other developers involved with WP/bbPress so that we can improve the compatibility between these applications moving forward; i.e. so that this is not such a convoluted issue. You can help me out by referencing this post when/if you think it might give others some insight.

jaswrks referenced this issue Sep 6, 2014
…ation is warranted here, along with a possible WP/bbPress bug report regarding the `is_search` flag.
jaswrks pushed a commit that referenced this issue Sep 6, 2014
Workaround for WP v4 and bbPress. See: #321 ~ NOTE: A ...
@jaswrks
Copy link
Contributor Author

jaswrks commented Sep 6, 2014

We have implemented a workaround in s2Member that avoids this issue. I also posted a follow-up here in the bbPress forums. I'm hoping the bbPress devs can take a look at the s key issues as it relates to the most recent change in WordPress v4.0, where isset() is used instead of !empty().

The next release of s2Member will include the workaround implemented by the last commit in this thread. You can look for this to come ASAP (once final tests are completed, perhaps over the weekend or early next week). Until then, please see the "Suggested Workaround" that I (and others) have posted above. Thanks everyone!


Next release changelog:

  • (s2Member) WP v4.0 / bbPress Compat. A conflict between WordPress v4.0, bbPress v2.5.4 and the previous release of s2Member has been resolved. A symptom of this issue was to see the leading topic post missing from your bbPress forum threads.

    This was a complex issue related to changes in the most recent copy of WordPress where WP_Query::$is_search is flagged as TRUE when the s key isset() instead of !empty(). s2Member has implemented a workaround so that the conflict will no longer cause this problem for site owners running s2Member/bbPress.

    However, please note that some other 3rd-party plugins may still conflict in this way; when running the latest version of bbPress under WordPress v4.0. We are working to notify bbPress and other plugin authors about this issue; just to help others avoid the problem. While unconfirmed, some site owners reported that the Relevanssi search plugin may have some trouble with this also.

    For further details, please see http://bbpress.org/?p=151839. See also: this GitHub issue if you'd like all of the details regarding this workaround in the s2Member software.

@clavaque
Copy link
Contributor

clavaque commented Sep 6, 2014

👍

@jaswrks
Copy link
Contributor Author

jaswrks commented Sep 8, 2014

Closing this issue because we feel like the issue within s2Member has been resolved here. Coming in the next release of the software. However, please feel free to leave comments here if you have anything more you'd like to add. Thanks again!

@jaswrks
Copy link
Contributor Author

jaswrks commented Sep 9, 2014

This fix went out with the release of s2Member v140909. It's being distributed through WordPress.org, and through the s2Member Pro updater also. Please look for an update notice in your WP Dashboard to arrive shortly :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants