In llms.abstract.database.store.php, get() method is expecting read() method to always return an associate array even if read() will sometimes return a boolean.
In wp-content/plugins/lifterlms/includes/abstracts/llms.abstract.database.store.php, Line 170 is expecting $this->read( $key ) to always return an associative array. However, in the same /wp-content/plugins/lifterlms/includes/abstracts/llms.abstract.database.store.php file, the method read() defined in line 338 is allowed to return a false value, which is not an associative array. In other words, line 170 is not correct in expecting that the method read() will always return an associative array — hence the PHP warning. Note, however, that the read() method in /wp-content/plugins/lifterlms/includes/abstracts/llms.abstract.database.store.php is returning a false value since there is no corresponding session record in the wp_lifterlms_events database table.
Reproduction Steps
None.
Expected Behavior
Line 170 should not expect an associated array all the time, since a false can be returned.
Actual Behavior
Line 170 should not expect an associated array all the time, even if a false can be returned.
It seems like this line in the get() method needs to account for the possibility that the read() method returns false.
So this line:
$res = $this->read( $key )[ $key ];
Should become something like:
$data = $this->read( $key );
if( $data ) {
$res = $data[ $key ];
} else {
$res = false; // Or do we want something other than false here?
}
Easy check. However, it may be possible that fixing things way causes that get to return false in a situation where other code isn't expecting it and so we pass this issue on down. We will need to test some situations to make sure this fix doesn't cause other issues.
It's an easy check, but I'd rather not silence the error until we're able to figure out why and when data that's expected to be there isn't there. At the least log the error so it is visible in the error logs if/when it happens.