Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
530 stars 197 forks source link

Lesson: Resetting Multilingual Lesson Versions Causes Data Loss #7563

Open LluisR opened 5 months ago

LluisR commented 5 months ago

Steps to Reproduce

  1. Install Sensei LMS version 4.20.2 or higher.
  2. Create a course with at least one lesson.
  3. Set up PolyLang to manage multiple languages.
  4. Create different pages in multiple languages for a lesson using PolyLang.
  5. Attempt to save or modify a lesson in a language other than the default one.

What I Expected

The other language versions of the lesson should remain intact after saving or modifying the lesson in a specific language.

What Happened Instead

The other language versions of the lesson are reset, and the records of COURSE, MODULE, and PREREQUISITE corresponding to them are deleted from the database when saving or modifying the lesson in a specific language.

PHP / WordPress / Sensei LMS version

PHP version: 7.2 WordPress version: 6.4.3 Sensei LMS version tested: 4.22.0 (NOT WORKING) - 4.20.2 (WORKING)

mglucero commented 4 months ago

I have the same problem!

PHP version: 8.2.11 WordPress version: 6.5.3 Sensei LMS version: 4.24.0 Polylang version: 3.6.1 Also I'm using the Classic Editor plugin

We had to downgrade to version 4.20.2 of Sensei LMS to avoid this bug.

merkushin commented 3 months ago

Hi @LluisR @mglucero 👋

I tried to test it with WordPress 6.5.3, Sensei LMS 4.24.0, Course 1.3.7, Polylang 3.6.1.

I couldn't reproduce the issue as it is described above.

For me content wasn't deleted, however I noticed a lot of weird behaviour. For example, it tries to assign all lessons to the same course which leads to a mix of lessons from different languages in the Course Outline in the editor (on the frontend I still see only lessons for the default language): https://github.com/Automattic/sensei/issues/7604

I noticed that the Polylang doesn't allow us to add the language switcher is we use a block theme. There is no Menus under the Appearance.

Could you provide more detailed instructions on how to reproduce the issue? Please consider including additional information if it might affect the result: your theme, whether you use Learning mode or not, how you configured languages and menu, etc.

As a sidenote:

The behaviour could be affected by the changes for better compatibility with WPML (first of them was introduced in 4.21.0). As I noticed in Polylang documentation, they support some WPML APIs, so that might result in undesired behaviour for them.

Next time, when we get more detailed instructions on how to reproduce the issue, it is worth to follow the instructions with the commented out body of the init method in includes/wpml/class-wpml.php to make sure our compatibility code is the source of the issue.