Skip to content

Conversation

@m1r0
Copy link
Member

@m1r0 m1r0 commented Mar 21, 2025

Related to #7701 and #7770

Proposed Changes

  • Fixes an "early translation" PHP notice when the sensei_usage_tracking_send_usage_data cron schedule is added. The error is also visible when activating Sensei Pro for the first time. The issue is solved by moving the cron schedule initialization to the init hook, which is a somewhat standard practice. As a side effect, this approach also forces the wp_schedule_event to be called on init as well.

Testing Instructions

On WordPress 6.8 the deprecation notice can be seen even when the language is English. For ease of testing, the testing instructions target this version.

  1. Install the WordPress Beta Tester plugin.
  2. In Tools > Beta Testing, select Bleeding Edge and Beta/RC Only.
  3. Update to WordPress 6.8-beta3.
  4. Install the WP Crontrol plugin.
  5. Go to Tools -> Cron Events.
  6. To re-create the job, find the sensei_usage_tracking_send_usage_data cron and delete it.
  7. There should be no PHP notice generated, i.e. no PHP Notice: Function _load_textdomain_just_in_time was called incorrectly.
  8. Refresh the page and make sure the sensei_usage_tracking_send_usage_data job is re-created.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • 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
  • Code is tested on the minimum supported PHP and WordPress versions

@m1r0 m1r0 added this to the 4.24.6 milestone Mar 21, 2025
@m1r0 m1r0 self-assigned this Mar 21, 2025
@github-actions
Copy link

Test the previous changes of this PR with WordPress Playground.

@m1r0 m1r0 force-pushed the fix/early-translations-in-tracking branch from 2652426 to 132ee10 Compare March 21, 2025 15:18
@github-actions
Copy link

Test the previous changes of this PR with WordPress Playground.

@m1r0 m1r0 force-pushed the fix/early-translations-in-tracking branch from 132ee10 to 3b84567 Compare March 21, 2025 16:06
@github-actions
Copy link

Test the previous changes of this PR with WordPress Playground.

@github-actions
Copy link

Test the previous changes of this PR with WordPress Playground.

* @access private
*/
public function register_course_list_block_patterns() {
require __DIR__ . '/course-list/class-sensei-course-list-block-patterns.php';
Copy link
Member Author

@m1r0 m1r0 Mar 21, 2025

Choose a reason for hiding this comment

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

This file is already loaded by the composer autoloader, so there's no need to require it again. It was causing a Fatal error: Cannot declare class Sensei_Course_List_Block_Patterns, because the name is already in use when testing using multiple do_action( 'init' ) calls (check the tests code).

@m1r0 m1r0 marked this pull request as ready for review March 21, 2025 16:19
@m1r0 m1r0 requested a review from a team March 21, 2025 16:19
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.

Looks good and works well!
Also confirmed that the data is sent correctly when running the event.

@m1r0 m1r0 merged commit 1a1a15d into trunk Mar 27, 2025
22 checks passed
@m1r0 m1r0 deleted the fix/early-translations-in-tracking branch March 27, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants