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

Fix lesson bulk edit #7515

Merged
merged 2 commits into from Mar 1, 2024
Merged

Fix lesson bulk edit #7515

merged 2 commits into from Mar 1, 2024

Conversation

merkushin
Copy link
Member

Resolves #6992

I suppose something has changed in how the form works a few years ago. Updated the processing of data.

Proposed Changes

  • Fix lesson bulk edit.

Testing Instructions

  1. Create a lesson.
  2. Create a few lessons without assigning them to a course.
  3. Open lesson list in WP admin, check lessons and choose Edit as a bulk action, then Apply.
  4. Update Sensei specific properties (you can test WP properties as well, they are managed by WP), click Update.
  5. Make sure lessons have updated data.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Legacy courses (course without blocks) are tested
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@merkushin merkushin added this to the 4.21.1 milestone Feb 27, 2024
@merkushin merkushin requested a review from a team February 27, 2024 20:27
@merkushin merkushin self-assigned this Feb 27, 2024
@merkushin merkushin changed the title Fix/lesson bulk edit Fix lesson bulk edit Feb 27, 2024
Copy link

codecov bot commented Feb 27, 2024

Codecov Report

Attention: Patch coverage is 4.54545% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 51.50%. Comparing base (c39ebf7) to head (8f50047).
Report is 1 commits behind head on trunk.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7515      +/-   ##
============================================
- Coverage     51.51%   51.50%   -0.01%     
  Complexity    11231    11231              
============================================
  Files           622      622              
  Lines         47505    47511       +6     
  Branches        414      414              
============================================
  Hits          24471    24471              
- Misses        22701    22707       +6     
  Partials        333      333              
Files Coverage Δ
includes/class-sensei-lesson.php 35.96% <4.54%> (-0.09%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28aef97...8f50047. Read the comment docs.

Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well for me!

Copy link
Contributor

@Imran92 Imran92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected! 👍 👍 Just left a comment about a possible logic check change.

Also, do you think we should add an integration test here to make sure that if it breaks for some reason, we'll know? Because in this case, we didn't know how long it was broken for or what broke it. Having an integration test saving these meta fields can potentially save us from these scenarios I think

$quiz_grade_type = isset( $_REQUEST['quiz_grade_type'] ) ? sanitize_text_field( (string) wp_unslash( $_REQUEST['quiz_grade_type'] ) ) : '';

// Store the values for all selected posts.
$lesson_ids = $_REQUEST['post'] ?? array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- Input is sanitized in the next lines.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably assigning to the empty array here is not necessary, because we already checked if it is an array on line 4337

@merkushin
Copy link
Member Author

Thanks, @Imran92! You're right. I'll create a separate PR with a test for it.
Just want to include this fix into our alpha release.

@merkushin merkushin merged commit 82b79de into trunk Mar 1, 2024
23 of 25 checks passed
@merkushin merkushin deleted the fix/lesson-bulk-edit branch March 1, 2024 14:44
This was referenced Mar 1, 2024
@Imran92
Copy link
Contributor

Imran92 commented Mar 5, 2024

Added a comment about a performance concern here #7523 (comment)

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

Successfully merging this pull request may close these issues.

Bulk editing lessons does not work
3 participants