diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml deleted file mode 100644 index 64439513a2..0000000000 --- a/.github/workflows/test-e2e.yml +++ /dev/null @@ -1,98 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/test-e2e.yml} -# -### -name: Test E2E - -on: - workflow_dispatch: - pull_request: - # Once daily at 00:00 UTC. -# schedule: -# - cron: '0 0 * * *' - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - ### - # - # Setup the test matrix. - # - ### - set-matrix: - name: Setup Matrix - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.setup.outputs.matrix }} - steps: - - uses: actions/checkout@v2 - - id: setup - uses: gocodebox/.github/.github/actions/setup-matrix@trunk - - ### - # - # Run tests. - # - ### - test: - name: "WP ${{ matrix.WP }}" - needs: set-matrix - runs-on: ubuntu-latest - continue-on-error: ${{ matrix.allow-failure }} - - strategy: - fail-fast: false - matrix: ${{ fromJSON( needs.set-matrix.outputs.matrix ) }} - - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Environment - uses: gocodebox/.github/.github/actions/setup-e2e@trunk - with: - wp-version: ${{ matrix.WP }} - docker-user: ${{ secrets.DOCKER_USERNAME }} - docker-pass: ${{ secrets.DOCKER_PASSWORD }} - node-version: '16' - - - name: Run test suite - run: npm run test -- --verbose - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - if: failure() - with: - name: error-artifacts-wp-${{ matrix.WP }} - path: tmp/artifacts - - ### - # - # Check the status of the entire test matrix. - # - # This will succeed if all jobs from the `test` job's matrix succeed. It allows jobs marked with `allow-failure` - # to fail. - # - # This job can be used as a single status check for branch protection rules. Without this - # we would need to require every job in the above build matrix. - # - ### - status: - name: Test E2E Status - runs-on: ubuntu-latest - if: always() - needs: test - steps: - - name: Check overall matrix status - if: ${{ 'success' != needs.test.result }} - run: exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6884566265..febf77a499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ LifterLMS Changelog =================== +v7.7.2 - 2024-08-12 +------------------- + +##### Bug Fixes + ++ Fixes fatal error when updating from an old version. Thanks [@verygoodplugins](https://github.com/verygoodplugins)! [#2716](https://github.com/gocodebox/lifterlms/issues/2716) ++ Avoid errors on pages restricted by one or more memberships. [#2714](https://github.com/gocodebox/lifterlms/issues/2714) + + v7.7.1 - 2024-08-09 ------------------- diff --git a/class-lifterlms.php b/class-lifterlms.php index f734f84629..5c2475091c 100644 --- a/class-lifterlms.php +++ b/class-lifterlms.php @@ -34,7 +34,7 @@ final class LifterLMS { * * @var string */ - public $version = '7.7.1'; + public $version = '7.7.2'; /** * LLMS_Assets instance diff --git a/includes/class-llms-db-ugrader.php b/includes/class-llms-db-ugrader.php index 37078ee1f9..c00aafcf4c 100644 --- a/includes/class-llms-db-ugrader.php +++ b/includes/class-llms-db-ugrader.php @@ -51,6 +51,9 @@ class LLMS_DB_Upgrader { */ public function __construct( $db_version, $updates = null ) { + if ( ! LLMS_Install::$background_updater ) { + LLMS_Install::init_background_updater(); + } $this->updater = LLMS_Install::$background_updater; // Background updates may trigger a notice during a cron and notices might not be available. @@ -62,7 +65,6 @@ public function __construct( $db_version, $updates = null ) { $this->db_version = $db_version; $this->updates = $updates; - } /** @@ -98,7 +100,6 @@ public function can_auto_update() { * @param LLMS_DB_Upgrader $upgrader Instance of the database upgrader. */ return apply_filters( 'llms_can_auto_update_db', $autoupdate, $this->db_version, $this ); - } /** @@ -129,7 +130,6 @@ protected function get_callback_prefix( $info, $version ) { } return ''; - } /** @@ -178,7 +178,6 @@ public function enqueue_updates() { $this->updater->save(); add_action( 'shutdown', array( 'LLMS_Install', 'dispatch_db_updates' ) ); - } /** @@ -199,7 +198,6 @@ public function get_updates() { * @param LLMS_DB_Upgrader $upgrader Instance of the database upgrader. */ return apply_filters( 'llms_db_updates_list', $this->updates, $this ); - } /** @@ -217,12 +215,11 @@ public function get_required_updates() { return array_filter( $this->get_updates(), - function( $update_version ) use ( $db_version ) { + function ( $update_version ) use ( $db_version ) { return version_compare( $db_version, $update_version, '<' ); }, ARRAY_FILTER_USE_KEY ); - } /** @@ -236,7 +233,6 @@ public function has_required_updates() { $required = $this->get_required_updates( $this->db_version ); return ! empty( $required ); - } /** @@ -264,7 +260,6 @@ protected function show_notice_pending() { 'default_path' => LLMS_PLUGIN_DIR . 'includes/admin/views/notices/', ) ); - } /** @@ -284,7 +279,6 @@ protected function show_notice_started() { 'dismiss_for_days' => 0, ) ); - } /** @@ -313,7 +307,6 @@ public function show_notice_complete() { 'dismiss_for_days' => 0, ) ); - } /** @@ -341,7 +334,5 @@ public function update() { } return true; - } - } diff --git a/includes/functions/llms.functions.access.php b/includes/functions/llms.functions.access.php index 886a714c23..c9bd97e306 100644 --- a/includes/functions/llms.functions.access.php +++ b/includes/functions/llms.functions.access.php @@ -176,7 +176,6 @@ function llms_page_restricted( $post_id, $user_id = null ) { /* This filter is documented above. */ return apply_filters( 'llms_page_restricted', $results, $post_id ); - } /** @@ -355,7 +354,6 @@ function llms_is_post_restricted_by_drip_settings( $post_id, $user_id = null ) { $is_available = ( $drip_bypass && $user_id && llms_is_complete( $user_id, $lesson_id, 'lesson' ) ) || $lesson->is_available(); return $is_available ? false : $lesson_id; - } /** @@ -443,7 +441,6 @@ function llms_is_post_restricted_by_prerequisite( $post_id, $user_id = null ) { // Otherwise return false: no prerequisite. return false; - } /** @@ -491,7 +488,6 @@ function llms_is_post_restricted_by_time_period( $post_id, $user_id = null ) { $course = new LLMS_Course( $course_id ); return $course->is_open() ? false : $course_id; - } /** @@ -529,28 +525,25 @@ function llms_is_post_restricted_by_membership( $post_id, $user_id = null ) { return false; } - $memberships = get_post_meta( $post_id, '_llms_restricted_levels', true ); - $restricted = get_post_meta( $post_id, '_llms_is_restricted', true ); - $restricted_ids = array(); + $memberships = get_post_meta( $post_id, '_llms_restricted_levels', true ); + $restricted = get_post_meta( $post_id, '_llms_is_restricted', true ); if ( 'yes' === $restricted && $memberships && is_array( $memberships ) ) { - $student = llms_get_student( $user_id ); + $restriction_ids = array(); + $student = llms_get_student( $user_id ); - if ( ! $student ) { - $restriction_ids = $memberships; - } else { - // loop through the memberships. - foreach ( $memberships as $mid ) { + foreach ( $memberships as $mid ) { + if ( ! is_numeric( $mid ) || absint( $mid ) === 0 ) { + continue; + } - // set this as the restriction id. - $restriction_ids[] = absint( $mid ); + $restriction_ids[] = absint( $mid ); - // once we find the student has access break the loop, - // this will be the restriction that the template loader will check against later. - if ( $student->is_enrolled( $mid ) ) { - break; - } + // once we find the student has access break the loop, + // this will be the restriction that the template loader will check against later. + if ( $student && $student->is_enrolled( $mid ) ) { + break; } } @@ -559,7 +552,6 @@ function llms_is_post_restricted_by_membership( $post_id, $user_id = null ) { } return false; - } /** @@ -623,7 +615,6 @@ function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = nu return false; } - } /** @@ -648,5 +639,4 @@ function llms_is_quiz_accessible( $post_id, $user_id = null ) { } return false; - } diff --git a/lifterlms.php b/lifterlms.php index 3828ff9111..476c1c3403 100644 --- a/lifterlms.php +++ b/lifterlms.php @@ -10,7 +10,7 @@ * Plugin Name: LifterLMS * Plugin URI: https://lifterlms.com/ * Description: Complete e-learning platform to sell online courses, protect lessons, offer memberships, and quiz students. WP Learning Management System. - * Version: 7.7.1 + * Version: 7.7.2 * Author: LifterLMS * Author URI: https://lifterlms.com/ * Text Domain: lifterlms diff --git a/package-lock.json b/package-lock.json index 66bb813038..92a041b28d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lifterlms", - "version": "7.7.1", + "version": "7.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lifterlms", - "version": "7.7.1", + "version": "7.7.2", "license": "GPL-3.0", "dependencies": { "@babel/core": "^7.16.5", diff --git a/package.json b/package.json index b2b22a8858..da54e07ba2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lifterlms", - "version": "7.7.1", + "version": "7.7.2", "description": "LifterLMS by codeBOX", "repository": { "type": "git",