Can't create a first page: Illegal offset type #4794

Closed
opened 2026-02-05 09:16:20 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @CamaroSS on GitHub (May 24, 2024).

Describe the Bug

I can't create a single page after a fresh install due to a fatal error.
The page is in "pages" table as a draft, but I can't see it anywhere in the UI.

Illegal offset type

Environment

PHP Version: 8.1.26
BookStack Version: v24.05.1
Theme Configured:

#0 D:\path-to-bookstack-instance\BookStack\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1706): class_uses_recursive(Object(BookStack\Entities\Models\Chapter))

Full stack trace:
https://pastebin.com/h8LmtSeJ

Steps to Reproduce

  1. Create a new shelf
  2. Create a new book
  3. Create a new chapter
  4. Click "Create a new page"

Expected Behaviour

A page is created

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

v24.05.1

Originally created by @CamaroSS on GitHub (May 24, 2024). ### Describe the Bug I can't create a single page after a fresh install due to a fatal error. The page is in "pages" table as a draft, but I can't see it anywhere in the UI. Illegal offset type Environment PHP Version: 8.1.26 BookStack Version: v24.05.1 Theme Configured: #0 D:\path-to-bookstack-instance\BookStack\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1706): class_uses_recursive(Object(BookStack\Entities\Models\Chapter)) Full stack trace: https://pastebin.com/h8LmtSeJ ### Steps to Reproduce 1. Create a new shelf 2. Create a new book 3. Create a new chapter 4. Click "Create a new page" ### Expected Behaviour A page is created ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version v24.05.1
OVERLORD added the 🐛 Bug label 2026-02-05 09:16:20 +03:00
Author
Owner

@CamaroSS commented on GitHub (May 24, 2024):

I am not used to Laravel at all and don't have time to get too deep into this, so I just hacked into

BookStack\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php line 1706

- || (is_object($relation) && in_array(AsPivot::class, class_uses_recursive($relation), true));
+ || (is_object($relation) && in_array(AsPivot::class, class_uses_recursive(get_class($relation)), true));

It works good so far.

@CamaroSS commented on GitHub (May 24, 2024): I am not used to Laravel at all and don't have time to get too deep into this, so I just hacked into BookStack\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php line 1706 - || (is_object($relation) && in_array(AsPivot::class, class_uses_recursive($relation), true)); + || (is_object($relation) && in_array(AsPivot::class, class_uses_recursive(get_class($relation)), true)); It works good so far.
Author
Owner

@ssddanbrown commented on GitHub (May 24, 2024):

That's odd, class_uses_recursive should call get_class if it's appropriate already. This also is not something I'm able to reproduce. I'd be worried that your changes may be hiding a different issue.

  • Have you made any other changes to the code at all?
  • Do the update steps run without error?
  • Is there any additional detail for the error if you view it in the app debug log?
@ssddanbrown commented on GitHub (May 24, 2024): That's odd, `class_uses_recursive` [should call `get_class` ](https://github.com/laravel/framework/blob/69b244063f2c57763bd13be50a8e9d4125720609/src/Illuminate/Support/helpers.php#L88-L90) if it's appropriate already. This also is not something I'm able to reproduce. I'd be worried that your changes may be hiding a different issue. - Have you made any other changes to the code at all? - Do the [update steps](https://www.bookstackapp.com/docs/admin/updates/) run without error? - Is there any additional detail for the error if you view it in the [app debug log](https://www.bookstackapp.com/docs/admin/debugging/#error-log-file)?
Author
Owner

@CamaroSS commented on GitHub (May 24, 2024):

Sorry, the culprit was a local PHP misconfiguration, not an issue. Thanks!

@CamaroSS commented on GitHub (May 24, 2024): Sorry, the culprit was a local PHP misconfiguration, not an issue. Thanks!
Author
Owner

@virtadpt commented on GitHub (May 24, 2024):

@CamaroSS For future reference, what was the PHP misconfiguration in question?

@virtadpt commented on GitHub (May 24, 2024): @CamaroSS For future reference, what was the PHP misconfiguration in question?
Author
Owner

@CamaroSS commented on GitHub (May 24, 2024):

@CamaroSS For future reference, what was the PHP misconfiguration in question?

There was an auto_prepend_file that in turn included an autoloader for another vendor directory, so class loading was quite messed up.

@CamaroSS commented on GitHub (May 24, 2024): > @CamaroSS For future reference, what was the PHP misconfiguration in question? There was an auto_prepend_file that in turn included an autoloader for another `vendor` directory, so class loading was quite messed up.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4794