From 59fa61db86de184747415df701c44c71b2edbe60 Mon Sep 17 00:00:00 2001 From: Donna Peplinskie Date: Fri, 6 Sep 2024 11:39:40 -0400 Subject: [PATCH 1/9] Remove GitHub Actions workflow for coverage reports We need to speed up our CI and this report doesn't have much value. --- .github/workflows/code-coverage.yml | 74 ----------------------------- 1 file changed, 74 deletions(-) delete mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml deleted file mode 100644 index 3507eb3b58..0000000000 --- a/.github/workflows/code-coverage.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: PHP & JavaScript Code Coverage - -on: pull_request - -jobs: - coverage: - name: PHP and JS Test Coverage - runs-on: ubuntu-latest - continue-on-error: false - env: - WP_VERSION: latest - WP_MULTISITE: 0 - PHP_VERSION: 7.4 - services: - database: - image: mysql:5.6 - env: - MYSQL_ROOT_PASSWORD: root - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Get cached composer directories - uses: actions/cache@v3 - with: - path: ~/.cache/composer/ - key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} - - uses: actions/cache@v3 - with: - path: vendor/ - key: ${{ runner.os }}-vendor-${{ hashFiles('composer.lock') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - extensions: mysql - tools: composer - coverage: xdebug - - - name: Tool versions - run: | - php --version - composer --version - - - name: Install PHP dependencies - run: composer install --no-ansi --no-interaction --prefer-dist --no-progress --ignore-platform-reqs - - - name: Setup test environment - run: bash ./tests/bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 $WP_VERSION - - - name: Run tests with coverage - run: php -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-clover ./coverage.xml - - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Install JS dependencies - run: npm ci - - - name: Test JS - env: - NODE_OPTIONS: "--max_old_space_size=4096" - run: npm run test-js:coverage - - - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v3 From 90b089f2897fcde5d02a25300986422da63f26c8 Mon Sep 17 00:00:00 2001 From: Donna Peplinskie Date: Fri, 6 Sep 2024 15:25:50 -0400 Subject: [PATCH 2/9] Fix PHP deprecation notice in View Results block --- includes/blocks/class-sensei-block-view-results.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/blocks/class-sensei-block-view-results.php b/includes/blocks/class-sensei-block-view-results.php index 8ed5b44256..63fb8406fb 100644 --- a/includes/blocks/class-sensei-block-view-results.php +++ b/includes/blocks/class-sensei-block-view-results.php @@ -73,7 +73,8 @@ public function render( $attributes, $content ): string { } $results_link = Sensei_Course::get_view_results_link( $course_id ); - parse_str( wp_parse_url( $results_link, PHP_URL_QUERY ), $results_link_query_params ); + + parse_str( (string) wp_parse_url( $results_link, PHP_URL_QUERY ), $results_link_query_params ); $form_inputs = ''; foreach ( $results_link_query_params as $name => $value ) { From 4db01b7fb02b0d102a5242132363c63703b2fe40 Mon Sep 17 00:00:00 2001 From: Donna Peplinskie Date: Fri, 6 Sep 2024 15:26:56 -0400 Subject: [PATCH 3/9] Add change log entry --- changelog/fix-view-results-block-deprecated-notice | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-view-results-block-deprecated-notice diff --git a/changelog/fix-view-results-block-deprecated-notice b/changelog/fix-view-results-block-deprecated-notice new file mode 100644 index 0000000000..d4c3869257 --- /dev/null +++ b/changelog/fix-view-results-block-deprecated-notice @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix PHP deprecation notice in View Results block From 076f45a341add188460fb80ae450c7dbf1aa1676 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Mon, 9 Sep 2024 22:05:57 +0600 Subject: [PATCH 4/9] Use is_singular prop to fix the issue, queried_object_id to fix warning --- ...sei-unsupported-theme-handler-page-imitator.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php index 7cf5dbb5f4..65abe35dd6 100644 --- a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php +++ b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php @@ -94,12 +94,14 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited // Prevent comments form from appearing. - $wp_query->post_count = 1; - $wp_query->is_404 = false; - $wp_query->is_page = true; - $wp_query->is_single = true; - $wp_query->is_archive = false; - $wp_query->max_num_pages = 0; + $wp_query->post_count = 1; + $wp_query->is_404 = false; + $wp_query->is_page = true; + $wp_query->is_single = true; + $wp_query->is_singular = true; + $wp_query->queried_object_id = null; + $wp_query->is_archive = false; + $wp_query->max_num_pages = 0; Sensei_Unsupported_Theme_Handler_Utils::disable_comments(); From 704bd16bb778502b0503d0c06dd44e66277f4ab6 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 10 Sep 2024 00:08:27 +0600 Subject: [PATCH 5/9] Remove queried_object_id --- .../class-sensei-unsupported-theme-handler-page-imitator.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php index 65abe35dd6..6a1bc69e12 100644 --- a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php +++ b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php @@ -88,8 +88,8 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po // On taxonomy pages the queried_object must remain a WP_Term object. if ( ! is_tax() ) { $wp_query->queried_object = $post; - $wp_query->queried_object_id = $post->ID; } + $wp_the_query = $wp_query; // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited @@ -99,7 +99,6 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po $wp_query->is_page = true; $wp_query->is_single = true; $wp_query->is_singular = true; - $wp_query->queried_object_id = null; $wp_query->is_archive = false; $wp_query->max_num_pages = 0; From 0589c5e8c0fa3aeb503de99906d2df75307686e1 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 10 Sep 2024 00:32:20 +0600 Subject: [PATCH 6/9] Add test --- ...nsei-unsupported-theme-handler-course-archive.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit-tests/unsupported-theme-handlers/test-class-sensei-unsupported-theme-handler-course-archive.php b/tests/unit-tests/unsupported-theme-handlers/test-class-sensei-unsupported-theme-handler-course-archive.php index a445a630bf..3b3f5f06bd 100644 --- a/tests/unit-tests/unsupported-theme-handlers/test-class-sensei-unsupported-theme-handler-course-archive.php +++ b/tests/unit-tests/unsupported-theme-handlers/test-class-sensei-unsupported-theme-handler-course-archive.php @@ -137,6 +137,18 @@ public function testCourseArchivePage_WhenRendered_RendersQueryListBlockIfPageCo $this->assertStringContainsString( 'wp-block-sensei-lms-course-list', $post->post_content ); } + public function testHandleRequest_WhenCalled_SetsGlobalWpQueryWithCorrectIsSingularAndQueryObjectId() { + /* ARRANGE */ + Sensei_Setup_Wizard::instance()->pages->create_pages(); + + /* ACT */ + $this->handler->handle_request(); + + /* ASSERT */ + $this->assertTrue( is_singular() ); + $this->assertEquals( 0, get_queried_object_id() ); + } + /** * Helper to set up the current request to be a course archive page. This request * will be handled by the unsupported theme handler if the theme is not From 709efdbb91e0a91be5db6009a4b46dd3cd6df983 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 10 Sep 2024 00:37:12 +0600 Subject: [PATCH 7/9] Add changelog --- changelog/fix-archive-404-issue-in-hello-elementor | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-archive-404-issue-in-hello-elementor diff --git a/changelog/fix-archive-404-issue-in-hello-elementor b/changelog/fix-archive-404-issue-in-hello-elementor new file mode 100644 index 0000000000..b1af6ab11b --- /dev/null +++ b/changelog/fix-archive-404-issue-in-hello-elementor @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Hello elementor theme throwing 404 when rendering the Courses archive page From 8773d1ad62082123861a5ffe57c464c0bd104872 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 10 Sep 2024 00:41:17 +0600 Subject: [PATCH 8/9] Fix linting --- ...sei-unsupported-theme-handler-page-imitator.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php index 6a1bc69e12..bb9f514c26 100644 --- a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php +++ b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php @@ -94,13 +94,13 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited // Prevent comments form from appearing. - $wp_query->post_count = 1; - $wp_query->is_404 = false; - $wp_query->is_page = true; - $wp_query->is_single = true; - $wp_query->is_singular = true; - $wp_query->is_archive = false; - $wp_query->max_num_pages = 0; + $wp_query->post_count = 1; + $wp_query->is_404 = false; + $wp_query->is_page = true; + $wp_query->is_single = true; + $wp_query->is_singular = true; + $wp_query->is_archive = false; + $wp_query->max_num_pages = 0; Sensei_Unsupported_Theme_Handler_Utils::disable_comments(); From 81a865ae03b84ed2152de4852f94527978ce0453 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 10 Sep 2024 00:52:36 +0600 Subject: [PATCH 9/9] Fix linting issue --- .../class-sensei-unsupported-theme-handler-page-imitator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php index bb9f514c26..6a0dd5f4a9 100644 --- a/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php +++ b/includes/unsupported-theme-handlers/class-sensei-unsupported-theme-handler-page-imitator.php @@ -87,7 +87,7 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po $wp_query->posts = array( $post ); // On taxonomy pages the queried_object must remain a WP_Term object. if ( ! is_tax() ) { - $wp_query->queried_object = $post; + $wp_query->queried_object = $post; } $wp_the_query = $wp_query;