Sensei: Warning: count()... on single course page

Created on 19 Aug 2019  路  5Comments  路  Source: Automattic/sensei

Issue

When viewing single course page I see the following warning directly above the course content:

Warning: count(): Parameter must be an array or an object that implements Countable in /srv/users/userb5e5e69b/apps/userb5e5e69b/public/wp-includes/post-template.php on line 310

image

Previous discussion: p1565281011034100-slack-plugin-squad

Site Info

WP 5.2.2
PHP 7.3.8
Sensei + WCPC 2.2.0.1.1.0-beta.1

Other active plugins:

Companion Plugin | Version 1.8 by Osk
Jetpack by WordPress.com | Version 7.6 by Automattic
WooCommerce | Version 3.7.0 by Automattic
WooCommerce Memberships | Version 1.14.0 by SkyVerge
WooCommerce Services | Version 1.21.1 by Automattic
WooCommerce Stripe Gateway | Version 4.2.3 by WooCommerce
WooCommerce Subscriptions | Version 2.5.7 by Automattic

Active theme: Twenty Sixteen

Themes

I see the error when using Storefront, Twenty Sixteen and Twenty Seventeen, but not in Twenty Nineteen.

Plugins

The error remains when only Sensei LMS 2.1.2 is activated.

Settings

I have not found any settings that remove the error.

Courses [Pri] High [Status] Queued [Type] Bug

Most helpful comment

This is being caused by the lack of WordPress loop functions in the single-course.php template. This should be fixed when we fix https://github.com/Automattic/sensei/issues/2767.

All 5 comments

This is being caused by the lack of WordPress loop functions in the single-course.php template. This should be fixed when we fix https://github.com/Automattic/sensei/issues/2767.

This bug can be fixed by duplicating the single-course.php file into your theme, under a folder named sensei, and making these changes:

replace line 44 with these lines:

    <?php
        $page_object = get_page( get_the_ID() );
        echo apply_filters( 'the_content', $page_object->post_content );
    ?>

This allows the_content to be called outside of the loop, thus avoiding the error message.

May I make a PR with (a tidier version of) this code?

@robrecord PRs are always welcome!

Bumping to high as we receive a lot of reports of this. There's also potential that people who don't have PHP notices disabled give up on Sensei when they see this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donnapep picture donnapep  路  5Comments

danjjohnson picture danjjohnson  路  7Comments

donnapep picture donnapep  路  5Comments

MindyPostoff picture MindyPostoff  路  3Comments

richardmtl picture richardmtl  路  7Comments