From f2f1dd001f208bef101b1029d319b5f2e97bb6b8 Mon Sep 17 00:00:00 2001
From: Weston Wedding <wes@wawco.com>
Date: Sun, 29 Nov 2015 19:58:58 -0800
Subject: [PATCH] Fixed Issue #2625464: Viewing a Book Course Object while not
 enrolled in a related Course generates warnings.

---
 modules/course_book/course_book.classes.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/course_book/course_book.classes.inc b/modules/course_book/course_book.classes.inc
index 725b186..82104aa 100644
--- a/modules/course_book/course_book.classes.inc
+++ b/modules/course_book/course_book.classes.inc
@@ -85,7 +85,8 @@ class CourseObjectBook extends CourseObjectNode {
     if ($this->getOption('book_tracking') == 'all') {
       // Possibly a bug here. book_toc doesn't return inaccessible book pages.
       $mlids = array_keys(book_toc($this->node->nid, 99));
-      $viewed = array_keys(array_filter($this->getFulfillment()->getOption('book_fulfillment')));
+      $fulfillment = $this->getFulfillment()->getOption('book_fulfillment');
+      $viewed = $fulfillment ? array_keys(array_filter($fulfillment)) : array();
       if (!array_diff($mlids, $viewed)) {
         $this->getFulfillment()->setComplete(1)->save();
       }
-- 
1.8.4.msysgit.0

