[8] ErrorException in Books.php line 41

Trying to access array offset on value of type null

  1. $book = Book::with(['chapters' => function ($query) {
  2. $query->order('chapter_order');
  3. }])->find($id);
  4. } else {
  5. $book = Book::with(['chapters' => function ($query) {
  6. $query->order('chapter_order');
  7. }])->where('unique_id','=', $id)->find();
  8. }
  9. if (empty($book['cover_url'])) {
  10. $book['cover_url'] = $this->img_site.'/static/upload/book/'.$book['id'].'/cover.jpg';
  11. }
  12. $tags = [];
  13. if (!empty($book->tags) || is_null($book->tags)) {
  14. $tags = explode('|', $book->tags);
  15. }
  16. cache('book:' . $id, $book, null, 'redis');
  17. cache('tags:book:' . $id, $tags, null, 'redis');
  18. }
  19. $redis = RedisHelper::GetInstance();

Call Stack

  1. in Books.php line 41
  2. at Error::appError() in Books.php line 41
  3. at Books->index()
  4. at ReflectionMethod->invokeArgs() in Container.php line 395
  5. at Container->invokeReflectMethod() in Module.php line 131
  6. at Module->think\route\dispatch\{closure}()
  7. at call_user_func_array() in Middleware.php line 185
  8. at Middleware->think\{closure}()
  9. at call_user_func() in Middleware.php line 130
  10. at Middleware->dispatch() in Module.php line 136
  11. at Module->exec() in Dispatch.php line 168
  12. at Dispatch->run() in App.php line 432
  13. at App->think\{closure}()
  14. at call_user_func_array() in Middleware.php line 185
  15. at Middleware->think\{closure}()
  16. at call_user_func() in Middleware.php line 130
  17. at Middleware->dispatch() in App.php line 435
  18. at App->run() in index.php line 21

Environment Variables

GET Dataempty
POST Dataempty
Filesempty
Cookies
nav_switch booklist
Sessionempty
Server/Request Data
USER www
HOME /home/www
HTTP_USER_AGENT claudebot
HTTP_ACCEPT */*
HTTP_HOST www.1rtm.com
PATH_INFO
REDIRECT_STATUS 200
SERVER_NAME www.1rtm.com
SERVER_PORT 443
SERVER_ADDR 172.17.14.103
REMOTE_PORT 60160
REMOTE_ADDR 54.205.238.173
SERVER_SOFTWARE nginx/1.22.1
GATEWAY_INTERFACE CGI/1.1
HTTPS on
REQUEST_SCHEME https
SERVER_PROTOCOL HTTP/2.0
DOCUMENT_ROOT /www/wwwroot/xiaohuanxiong/public
DOCUMENT_URI /index.php
REQUEST_URI /book/kuai768
SCRIPT_NAME /index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD GET
QUERY_STRING s=/book/kuai768
SCRIPT_FILENAME /www/wwwroot/xiaohuanxiong/public/index.php
FCGI_ROLE RESPONDER
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1711615012.1816
REQUEST_TIME 1711615012
Environment Variablesempty
ThinkPHP Constants
BOOKCTRL book
CHAPTERCTRL chapter
TAGCTRL tag
BOOKLISTACT booklist
SEARCHCTRL search
RANKCTRL rank
UPDATEACT update
AUTHORCTRL author
spider_db_conn xxx
PINYIN_DEFAULT 4096
PINYIN_TONE 2
PINYIN_NO_TONE 4
PINYIN_ASCII_TONE 8
PINYIN_NAME 16
PINYIN_KEEP_NUMBER 32
PINYIN_KEEP_ENGLISH 64
PINYIN_UMLAUT_V 128
PINYIN_KEEP_PUNCTUATION 256