Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic and reply content not displaying


  • tamarazuk
    Participant

    @tamarazuk

    Hi,

    I am unable to view the topic or reply content. With debug on I receive the following error

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FORCE INDEX (PRIMARY, post\_parent) WHERE 1=1 AND (wp\_posts.ID = 647 OR wp\_posts.’ at line 2] SELECT SQL\_CALC\_FOUND\_ROWS wp\_posts.* FROM wp\_posts JOIN wp\_icl\_translations t ON wp\_posts.ID = t.element\_id AND t.element\_type IN (‘post\_topic’) JOIN wp\_icl\_languages l ON t.language\_code=l.code AND l.active=1 FORCE INDEX (PRIMARY, post\_parent) WHERE 1=1 AND (wp\_posts.ID = 647 OR wp\_posts.post\_parent = 647) AND wp\_posts.post\_type IN (‘topic’, ‘reply’) AND (wp\_posts.post\_status = ‘publish’ OR wp\_posts.post\_status = ‘closed’) AND t.language\_code=’en’ ORDER BY wp\_posts.post\_date ASC LIMIT 0, 15

    I have had this error since I installed this plugin over a month ago and have not been able to fix it. At that time I found this ticket1 which lead me to this 2 line change2. I decided to add these two lines but that did not help either.

    I have switched themes to Twenty Ten bbPress, Twenty Eleven, and the standard Twenty Eleven. I have also disabled almost all plugins (not WPML because I’ve had bad experiences with disabling and re-enabling it). None of this troubleshooting actions have helped. I then sat around waiting for an update, but unfortunately one has not come yet.

    Since we are reaching the launch date I would like any help from anyone who has encountered this issue and successfully fixed it.

    Thank you so much! Tamara

    • This topic was modified 12 years, 1 month ago by tamarazuk.
Viewing 9 replies - 1 through 9 (of 9 total)

  • tamarazuk
    Participant

    @tamarazuk

    I hate to bump this, but I would love some direction on this.
    At least some troubleshooting steps I have not yet taken.


    villagora
    Participant

    @villagora

    hi tamarazuk,

    Indeed, that seems to be the same error [ticket #1938][1]. But in our case, we have modified bbp_has_replies args for to add our own meta queries…
    In your case, it seems that the plugin WPML add a join clause to the bbppress query :

    > JOIN wp_icl_translations t ON wp_posts.ID = t.element_id

    That’s why the SQL query crash… I suggest you to backup your db & disable WPML for confirm my diagnostic ! 😉

    Some ideas for fix it :

    • wait the bbpress update
    • if you have programing skills, you can try to hook the posts_join or posts_where probably used by WPML for fix manualy the querry.

    Good luck !


    tamarazuk
    Participant

    @tamarazuk

    Hi Villagora,

    Thank you so much for your reply! You are absolutely right, WPML is causing the problem. I have spent the whole day investigating hoping that I could write something meaningful here, however, that is not the case. I will contact WPML for further support and post back here if I hear anything that could be of use to other people.

    Thanks again!


    zaerl
    Participant

    @zaerl

    The problem here is that bbPress insert a FORCE INDEX (PRIMARY, post_parent) but WPML uses a JOIN in its tables. You can’t do that when you have a JOIN cause the correct syntax in that particular case is FORCE INDEX FOR JOIN. Try to replace the function “function _bbp_has_replies_where( $where, $query )” in wp-content/plugins/bbpress/bbp-includes/bbp-replay-functions.php” with this: https://gist.github.com/3930162

    Keep in mind that it’s not tested, I haven’t a WPML license. I do not know either if my reasoning makes sense at all.


    tamarazuk
    Participant

    @tamarazuk

    zaerl,
    Thank you for your help. Unfortunately, I now get a different but similar error (notice the addition of the ‘FOR’:


    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FORCE INDEX FOR JOIN (PRIMARY, post_parent) WHERE 1=1 AND (wp_posts.ID = 647 OR ' at line 2]
    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type IN ('post_topic') JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 FORCE INDEX FOR JOIN (PRIMARY, post_parent) WHERE 1=1 AND (wp_posts.ID = 647 OR wp_posts.post_parent = 647) AND wp_posts.post_type IN ('topic', 'reply') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed') AND t.language_code='en' ORDER BY wp_posts.post_date ASC LIMIT 0, 15

    I am still learning programming in WP and my SQL skills are pretty much non-existent.


    tamarazuk
    Participant

    @tamarazuk

    WPML gives free licences to developers looking to make their themes or plugins compatible. Given this, it might be acceptable that I give you access to my CMS licence if it fixes the bbPress compatibility issue. What do you think?


    zaerl
    Participant

    @zaerl

    I’ve checked the documentation of FORCE INDEX, forget the “solution” I’ve posted above. Actually speaking this snippet (maybe) work:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts FORCE INDEX (PRIMARY, post_parent) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type IN ('post_topic') JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 WHERE 1=1 AND (wp_posts.ID = 647 OR wp_posts.post_parent = 647) AND wp_posts.post_type IN ('topic', 'reply') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed') AND t.language_code='en' ORDER BY wp_posts.post_date ASC LIMIT 0, 15
    

    Notice the positioning of the FORCE INDEX. Unfortunately we can’t change that part of the query from ‘_bbp_has_replies_where’. We must use the ‘posts_join’ filter, check if WPML have injected its stuff and add the FORCE INDEX.


    tamarazuk
    Participant

    @tamarazuk

    [SOLVED]
    First I’d like to thank villagora and zaerl for their help!

    I have realized that the issue was that I had set the CPTs Forums, Topics and Replies to “Translate” in WPML settings. It was probably something I did when I installed bbPress and overlooked the fact after during my debugging.

    For anyone else who is trying to run WPML and bbPress together please note that Forums cannot be translated with WPML. Instead, you must create a separate forum for each language.

    Cheers!


    zaerl
    Participant

    @zaerl

    I’m glad but yours is a workaround the problem. Maybe in future release bbPress will reconsider the FORCE INDEX.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar