maximeschoeni / sublanguage

Multilanguage plugin for wordpress
42 stars 13 forks source link

BuddyPress/BBPress errors #17

Open misiman opened 7 years ago

misiman commented 7 years ago

Hi,

Your plugin looks like it could be really perfect for my requirements, lightweight and with inheritance.

However, I am testing the latest version (2?) from the Github repo and have found it conflicts with BuddyPress and/or BBPress with the following errors produced in the Admin console:

1) Notice: Trying to get property of non-object in C:\Websites\www.example.dev\wp-content\plugins\bbpress\includes\common\functions.php on line 1446 which appears to be related to bbp_query_post_parent__in( )

2) Warning: in_array() expects parameter 2 to be array, null given in C:\Websites\www.example.dev\wp-content\plugins\bbpress\includes\common\functions.php on line 1446 which also appears to be related to bbp_query_post_parent__in( ) but specifically the call to in_array ( )

It would be great to resolve these issues because BuddyPress and BBPress are commonly used plugins.

Thanks

maximeschoeni commented 7 years ago

Hello, thank you for your report, I will check this. The 2.0 version is not stable yet but it should be soon. I am actually trying to foresee issues it may have with other plugins.

maximeschoeni commented 7 years ago

I think this is a problem in BBPress. I submitted a fix. Hope they will patch it!

misiman commented 7 years ago

Nice detective work.

Do you know why the BBPress issue only presents itself after activating Sublanguage? I can see the problem you highlight, I would just like to understand the logic behind why the conflict doesn't manifest itself with other plugins I've used.

Many thanks.

maximeschoeni commented 7 years ago

This conflict happens every time a plugin needs to query database (using WP_Query class) before a certain point. Sublanguage needs to fetch the language items very soon, that's when the error is triggered. Your other plugins don't need to do query so early, that's why they don't trigger it.

Alternatively I could also avoid using WP_Query class and use a raw SQL query instead. On second look it doesn't sound bad because it would also prevent other conflicts... I'll definitely consider it. Thank you for submitting this issue!

misiman commented 7 years ago

Thanks for the explanation - a well sanitised raw SQL query sounds like the best option.

Do you know when the earliest v2 RC will be available?

maximeschoeni commented 7 years ago

The main drawback of this approach is about cache: a raw sql query does not benefit from a cache plugins in case there is one.

I hope it will be ready next week.

misiman commented 7 years ago

Hi again,

The new plugin looks really good. Am I right in thinking that post translations are now stored in post_meta rather than wp_posts?

Does this cause a problem for the standard Wordpress mechanisms for free-text searching post content?

Thanks

maximeschoeni commented 7 years ago

Yes, you're right, from 2.0, translations are stored in post_meta. It is a less hacky way of doing and it improves general compatibility. But as you point, it also cause problem with the wordpress search system. I am aware of this and I am looking for a fix.

misiman commented 7 years ago

Ok, thanks.

This is an important feature for me (and I expect for most others using translation), because free-text search in any supported language locale is pretty essential to a good user experience.