production.ERROR: BookStack\Users\Models\User::getGuest():
Attempted Debugging
- [x] I have read the debugging page
Searched GitHub Issues
- [x] I have searched GitHub for the issue.
Describe the Scenario
I had to do a recovery on a database corruption that damaged the Bookstack database I had running.. I think the database I had was Mariadb 10.1 and I recall having to upgrade to 10.6 in order to update to the latest BookStack running in December. I have recovered the DB in MariaDB 10.1 but the error I am receiving seems to indicate a DB issue (guess). I am not sure of the best way that I have a DB that is compatible with v24.12 which is what I have. Is there a way to confirm the DB integrity and version?
Thanks
Exact BookStack Version
v24.12
Log Content
[2025-06-15 23:20:12] production.ERROR: BookStack\Users\Models\User::getGuest(): Return value must be of type BookStack\Users\Models\User, null returned {"exception":"[object] (TypeError(code: 0): BookStack\\Users\\Models\\User::getGuest(): Return value must be of type BookStack\\Users\\Models\\User, null returned at /www/pcvbook/BookStack/app/Users/Models/User.php:98)
[stacktrace]
#0 /www/pcvbook/BookStack/app/App/helpers.php(38): BookStack\\Users\\Models\\User::getGuest()
#1 /www/pcvbook/BookStack/app/Http/Middleware/Localization.php(26): user()
#2 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\Localization->handle()
#3 /www/pcvbook/BookStack/app/Http/Middleware/RunThemeActions.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#4 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\RunThemeActions->handle()
#5 /www/pcvbook/BookStack/app/Http/Middleware/CheckEmailConfirmed.php(47): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#6 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\CheckEmailConfirmed->handle()
#7 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#8 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#9 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#10 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#11 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#12 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#13 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle()
#14 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#15 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#16 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#17 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#18 /www/pcvbook/BookStack/app/Http/Middleware/ApplyCspRules.php(33): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#19 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\ApplyCspRules->handle()
#20 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then()
#22 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack()
#23 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute()
#24 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute()
#25 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#26 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#27 /www/pcvbook/BookStack/app/Http/Middleware/PreventResponseCaching.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#28 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\PreventResponseCaching->handle()
#29 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#30 /www/pcvbook/BookStack/app/Http/Middleware/TrustProxies.php(41): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#31 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): BookStack\\Http\\Middleware\\TrustProxies->handle()
#32 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#33 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#34 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#35 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#37 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#39 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#41 /www/pcvbook/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#42 /www/pcvbook/BookStack/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#43 {main}
Hosting Environment
IBM i PASE environment - Roughly AIX 7.2 (not an issue really, BookStack ran great prior to the DB corruption)
Hi @phelgren,
That's odd. As a first step, if you look at the users table in the database is there data?
- Is there a
system_namecolumn? - Is there a row where the
system_nameispublic?
Yes. There are only two records in the table. One is for admin and the system name is blank in that row, and one for guest and the system name is 'licgue' in that row
Pete Helgren www.petesworkshop.com CISSP - MSCM GIAC Cloud Penetration Tester AWS Certified Cloud Practitioner Microsoft Certified: Azure Fundamentals
Hi @phelgren,
Okay, that's strange. The licgue looks like it's maybe a malformed combination of Public and guest.
What kind of recovery process did you end up performing in this environment?
I used an application called Stellar Repair because my DIY attempts didn't bear any fruit. What should the values be? Also, it seems that all of the records have a "deleted at" date...is that normal? Finally, on the pages table the "editor" column has a value of iwyg - that doesn't look right either...
Okay, I'm not convinced you have healthly repaired database content at this stage. What kind of prior files and/or backups do you have available?
I don't have a backup of any value. I do have a very early DB that I used to test with. I have been comparing the two DB's, table by table. The one I really need is really jacked up. Many slugs are truncated or garbled, I don't know why. But I put too much time into the book to start over at this point. I guess I'll just have to do a side by side until the app starts responding again. I might start with fresh db, add a few chapters and pages to get a sense of what the values really should be and then manually update the tables in the corrupted DB.
Learning a few valuable lessons but I never anticipated a DB corruption like this so I'll just do what I can.
And, if I DO want to start with an empty DB, do I just rename the existing DB and then use php artisan migrate to initialize the DB in the existing BookStack app?
Do you still have the files from before any attempted fixes (Especially via Stellar Repair)? I've been able to help a handful of folks in the past who have ended up in corrupted states.
Thanks for the offer...here is what I think happened but I am not sure. I wanted to upgrade Bookstack but noticed that it required 10.2 of MariaDB or higher. So I "upgraded" to 10.6, upgrade is in quotes because I think I installed a separate instance of MariaDB rather than upgrade what was there. I am not sure what I ended up with. The DB folder containing the 10.1 version seemed to have all the records of the new pages I added after the BookStack upgrade, which made no sense since the new install "seemed" to be pointed to a different folder. But I discovered this after the system had been shut down and shipped to a new location. When the system came up, I had issues starting two WordPress instances and the Bookstack instance so I assumed there was an error in starting the Mariadb instances. I was finally able to at least start the Mariadb instances but still no joy in starting the apps using the DB's. So I opened up the DB instances with an SQL client and all seemed well until I started perusing the tables. I got a series of "Table xxx doesn't exist..." errors even through you could see the table entries in the DB. It was hit or miss as well. Not all the DB's were corrupted. Some were just fine. Attempting to repair the DB's with DIY methods found on the web didn't help. I didn't perform those repairs on the original folders, only copies of them.
As I think it through, after the install of 10.6 and starting that Mariadb instance I am beginning to wonder if somehow the folders the Mariadb instances got "crossed": some pointing to the old location and some to the new, so some the db folders were mixed (don't even know if this is possible) I do know that after I discovered that things were a mess, I took snapshots of the DB folders. I have been making copies of those folders as I have attempted to repair them, rather than working directly on the backed-up folders. I do recall seeing an error message when I attempted to open the DB's initially something like "created at 10121 but opened at 10621" (or something like that).
I would just like to get everything to the 10.6 level. Bookstack is one of the critical DB's and I have another, much more complex one that I would like to recover as well. Stellar has not been, well. stellar in getting the corruption fixed....
Yeah, In the rare few times I've had corruption reported, accidentally running multiple databases against the same data has been a cause, which of course docker makes easier than normal.
I've had success before opening up the files with a mariadb container, that's specifically matched to the content version, although not starting the default mariadb process, but instead manually running safe-mode/recovery commands (can't remember exactly) to recover via the old version, then (once a safe sqldump had been made), safely walk the data up some versions.
Since there's been no further follow-up I'm going to close this off. Just ask if further support is needed though.