BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Code instead of wiki pages

Open Jens-TGS opened this issue 7 months ago • 20 comments

Attempted Debugging

  • [x] I have read the debugging page

Searched GitHub Issues

  • [x] I have searched GitHub for the issue.

Describe the Scenario

I already did several updates of my nice bookstack installation, but this time when updating to 25.02.5 things went wrong. If I now open my wiki URL, I'm getting redirected to

https://wiki.my-domain.com/login

and this page looks like this:

`@extends('layouts.simple') @section('content')

{{ Str::title(trans('auth.log_in')) }} @include('auth.parts.login-message') @include('auth.parts.login-form-' . $authMethod) @if(count($socialDrivers) > 0) @foreach($socialDrivers as $driver => $name) @icon('auth/' . $driver) {{ trans('auth.log_in_with', ['socialDriver' => $name]) }} @endforeach @endif @if(setting('registration-enabled') && config('auth.method') === 'standard') {{ trans('auth.dont_have_account') }} @endif @stop`

Any idea how to restore my wiki?

If not: it's not a major issue. I do have a plenty of backups of the VM running the wiki.

Exact BookStack Version

25.02.5

Log Content

No helpful entries

Hosting Environment

Debian 12 (bookworm) VM served by Proxmox apache 2.4.62 php 8.3.21 Proxy: Nginx Proxy Manager

Jens-TGS avatar May 26 '25 20:05 Jens-TGS

Hi @Jens-TGS, This usually occurs when there's an issue with file permissions of certain files/folders. I've advise:

  • Follow our guidance to reset the needed file and folder permissions for your BookStack instance: https://www.bookstackapp.com/docs/admin/filesystem-permissions/
  • Delete any files ending in .php that exist in the bootstrap/cache folder relative to your BookStack install location.

ssddanbrown avatar May 26 '25 23:05 ssddanbrown

Dear Dan,

thanks a lot for the quick advices. I did follow them, unfortunately they did not solve my issue.

Here is how the /var/www/bookstack folder looks like at the moment:

root@mywiki:/var/www/bookstack# ls -al
total 2063
drwxr-xr-x 16 www-data www-data      42 May 26 22:33 .
drwxr-xr-x  5 root     root           5 May 27 06:23 ..
-rw-r--r--  1 www-data www-data    5928 May 26 22:28 .env
-rwxr-xr-x  1 www-data www-data    4904 Dec  3  2022 .env.bak
-rwxr-xr-x  1 www-data www-data    1665 May 26 22:33 .env.example
-rwxr-xr-x  1 www-data www-data   13938 May 26 22:33 .env.example.complete
-rwxr-xr-x  1 www-data www-data    4988 Aug 27  2024 .env.lmn-ldap
drwxr-xr-x  8 www-data www-data      15 May 26 22:33 .git
-rwxr-xr-x  1 www-data www-data      61 May 26 22:33 .gitattributes
drwxr-xr-x  4 www-data www-data       8 May 26 22:33 .github
-rwxr-xr-x  1 www-data www-data     461 May 26 22:33 .gitignore
-rwxr-xr-x  1 www-data www-data    1122 May 26 22:33 LICENSE
drwxr-xr-x 23 www-data www-data      23 Mar  3 20:14 app
-rwxr-xr-x  1 www-data www-data    1685 May 26 22:33 artisan
-rwxr-xr-x  1 www-data www-data  388792 May 26 22:33 bookstack-system-cli
drwxr-xr-x  3 www-data www-data       5 May 26 22:33 bootstrap
-rwxr-xr-x  1 www-data www-data    3656 May 26 22:33 composer.json
-rwxr-xr-x  1 www-data www-data  380388 May 26 22:33 composer.lock
-rwxr-xr-x  1 www-data www-data 2799637 Aug 21  2022 composer.phar
-rwxr-xr-x  1 www-data www-data     304 May 26 22:33 crowdin.yml
drwxr-xr-x  5 www-data www-data       6 May 26 22:33 database
drwxr-xr-x  8 www-data www-data       8 Apr 14 23:07 dev
-rwxr-xr-x  1 www-data www-data    1370 May 26 22:33 docker-compose.yml
-rwxr-xr-x  1 www-data www-data    1689 May 26 22:33 eslint.config.mjs
-rwxr-xr-x  1 www-data www-data    6833 May 26 22:33 jest.config.ts
drwxr-xr-x 53 www-data www-data      53 Mar  3 20:14 lang
-rwxr-xr-x  1 www-data www-data  333307 May 26 22:33 package-lock.json
-rwxr-xr-x  1 www-data www-data    2439 May 26 22:33 package.json
-rwxr-xr-x  1 www-data www-data    1967 Apr  5  2024 pakete-nicht-debian.txt
-rwxr-xr-x  1 www-data www-data    1045 May 26 22:33 phpcs.xml
-rwxr-xr-x  1 www-data www-data     465 May 26 22:33 phpstan.neon.dist
-rwxr-xr-x  1 www-data www-data    3154 May 26 22:33 phpunit.xml
drwxr-xr-x  5 www-data www-data      20 May 26 22:33 public
-rwxr-xr-x  1 www-data www-data   14569 May 26 22:33 readme.md
drwxr-xr-x  6 www-data www-data       6 Mar 26  2023 resources
drwxr-xr-x  2 www-data www-data       4 May 26 22:33 routes
drwxrwxr-x  9 www-data www-data       9 May  6  2023 storage
drwxr-xr-x 19 www-data www-data      31 May 26 22:33 tests
drwxr-xr-x  2 www-data www-data       3 May 26 22:33 themes
-rwxr-xr-x  1 www-data www-data     640 May 26 22:33 tsconfig.json
drwxr-xr-x 48 www-data www-data      49 May 26 22:33 vendor
-rwxr-xr-x  1 www-data www-data       9 May 26 22:33 version

Any other ideas about the root cause?

BR, Jens

Jens-TGS avatar May 27 '25 04:05 Jens-TGS

Ah, okay.

  • What is the full output of running git status from your BookStack install folder?
  • What is the full output of running git log -n 1 from your BookStack install folder?
  • What is the full output of running ls -alh bootstrap/cache from your BookStack install folder?
  • What is the full output of running ls -alh storage/framework/views | head from your BookStack install folder?
  • Can you re-run each of the update commands, and share the full output of each?

ssddanbrown avatar May 27 '25 12:05 ssddanbrown

Also, possibly related to #5433. Worth checking your PHP packages are updated and aligned, as from that thread the finding was that differing package versions could lead to this. Could be likely in this case since it looks like you're not just using standard debian packages for PHP (I'm assuming deb sury packages?).

ssddanbrown avatar May 27 '25 12:05 ssddanbrown

Thanks a lot for your posts. I really do appreciate your support.

I did read #5433, but did not get any advice how to proceed here. Yes, my PHP packages are deb sury packages:

root@wiki:/var/www/bookstack# cat /etc/apt/sources.list.d/sury-php.list
deb https://packages.sury.org/php/ bookworm main

And everything is up to date (and was also before):

root@wiki:/var/www/bookstack# apt update
Hit:1 http://security.debian.org bookworm-security InRelease
Hit:2 http://ftp.debian.org/debian bookworm InRelease
Hit:3 http://ftp.debian.org/debian bookworm-updates InRelease
Hit:4 https://packages.sury.org/php bookworm InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

Coming to your first post from today. Here are the requested outputs:

From git status I believe all files are modified (output truncated):

root@wiki:/var/www/bookstack# sudo -u www-data git status
On branch release
Your branch is up to date with 'origin/release'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .env.example
        modified:   .env.example.complete
        modified:   .gitattributes
        modified:   .github/CODE_OF_CONDUCT.md
        modified:   .github/FUNDING.yml
        modified:   .github/ISSUE_TEMPLATE/api_request.yml
        modified:   .github/ISSUE_TEMPLATE/bug_report.yml
        modified:   .github/ISSUE_TEMPLATE/config.yml
        modified:   .github/ISSUE_TEMPLATE/feature_request.yml
        modified:   .github/ISSUE_TEMPLATE/language_request.yml
        modified:   .github/ISSUE_TEMPLATE/support_request.yml
        modified:   .github/SECURITY.md
        modified:   .github/translators.txt
        modified:   .github/workflows/analyse-php.yml
        modified:   .github/workflows/lint-js.yml
        modified:   .github/workflows/lint-php.yml
        modified:   .github/workflows/test-js.yml
        modified:   .github/workflows/test-migrations.yml
        modified:   .github/workflows/test-php.yml
        modified:   .gitignore
        modified:   LICENSE
        modified:   app/Access/Controllers/ConfirmEmailController.php
        modified:   app/Access/Controllers/ForgotPasswordController.php
        modified:   app/Access/Controllers/HandlesPartialLogins.php
        modified:   app/Access/Controllers/LoginController.php
        modified:   app/Access/Controllers/MfaBackupCodesController.php
        modified:   app/Access/Controllers/MfaController.php
        modified:   app/Access/Controllers/MfaTotpController.php
        modified:   app/Access/Controllers/OidcController.php
        modified:   app/Access/Controllers/RegisterController.php
...

But if I do have a look at the details, just the access rights are modified:

root@wiki:/var/www/bookstack# sudo -u www-data git diff app/Access/Controllers/ConfirmEmailController.php
diff --git a/app/Access/Controllers/ConfirmEmailController.php b/app/Access/Controllers/ConfirmEmailController.php
old mode 100644
new mode 100755

Other requested outputs:

root@wiki:/var/www/bookstack# sudo -u www-data git log -n 1
commit 73f9834e6f591cd61115a31a44ba9a684c136390 (HEAD -> release, origin/release)
Author: Dan Brown <[email protected]>
Date:   Sat May 17 12:16:55 2025 +0100

    Updated version and assets for release v25.02.5
root@wiki:/var/www/bookstack# ls -alh bootstrap/cache
total 15K
drwxrwxr-x 2 www-data www-data   5 May 27 06:24 .
drwxr-xr-x 3 www-data www-data   5 May 26 22:33 ..
-rwxrwxr-x 1 www-data www-data  14 May 26 22:33 .gitignore
-rwxrwxr-x 1 www-data www-data 802 May 27 06:24 packages.php
-rwxrwxr-x 1 www-data www-data 22K May 27 06:24 services.php
root@wiki:/var/www/bookstack# ls -alh storage/framework/views | head
total 51K
drwxrwxr-x 2 www-data www-data    7 May 27 15:49 .
drwxrwxr-x 5 www-data www-data    6 May 26 22:33 ..
-rwxrwxr-x 1 www-data www-data   14 May 26 22:33 .gitignore
-rwxrwxr-x 1 www-data www-data 2.8K May 26 22:34 546f2f1017bec334b37dedb3f82bcfa3.php
-rw-r--r-- 1 www-data www-data 2.5K May 27 15:49 a0effcbb5c1d35baf0ecb90d3e862545.php
-rwxrwxr-x 1 www-data www-data 1.3K May 26 22:34 ae53f06791072e4f2e88a01c5fb6687b.php
-rwxrwxr-x 1 www-data www-data 1.4K May 26 22:35 e7236d2133250d3904f9a5019cd545f6.php

Run again update process:

root@wiki:/var/www/bookstack# sudo -u www-data git pull origin release
From https://github.com/BookStackApp/BookStack
 * branch                release    -> FETCH_HEAD
Already up to date.
root@wiki:/var/www/bookstack# sudo -u www-data composer install --no-dev
> @php -r "!file_exists('bootstrap/cache/services.php') || @unlink('bootstrap/cache/services.php');"
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/socialite ........................................................................................................................... DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/termwind ......................................................................................................................... DONE
  socialiteproviders/manager .................................................................................................................. DONE

58 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan cache:clear

   INFO  Application cache cleared successfully.

> @php artisan view:clear

   INFO  Compiled views cleared successfully.

root@wiki:/var/www/bookstack# sudo -u www-data php artisan migrate


                                                                                APPLICATION IN PRODUCTION.


 ┌ Are you sure you want to run this command? ──────────────────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

   INFO  Nothing to migrate.

Jens-TGS avatar May 27 '25 17:05 Jens-TGS

Thanks @Jens-TGS for the detail. That's all looking generally fine though, no surprises. Gonna have to dig into things a little more.

  • What's the output of running php -r "echo token_get_all('cat')[0][0] === T_INLINE_HTML ? 'pass' : 'fail';"?
  • Are you confident that PHP running via apache is running via the same version as reported (which I assumed was confirmed via command line)?
    • Just asking as multiple versions of PHP could potentially be in play in a scenario like this.
    • How is PHP being ran via apache? PHP module, or via separate php-fpm process, or unknown?
  • In the BookStack folder, can you run git config core.fileMode false to ignore file permission changes then re-confirm the git status output. Should be much reduced in output lines.

ssddanbrown avatar May 27 '25 17:05 ssddanbrown

Of course, here are the requested additional details:

root@wiki:/var/www/bookstack# sudo -u www-data php -r "echo token_get_all('cat')[0][0] === T_INLINE_HTML ? 'pass' : 'fail';"
pass

I'm not the biggest expert in apache2 and which version it is running, but I believe, it is the reported version, since nothing else is installed:

root@wiki:/var/www/bookstack# dpkg -l | grep php
ii  libapache2-mod-php8.3          8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-common                     2:96+0~20250402.56+debian12~1.gbp84a5b7     all          Common files for PHP packages
ii  php8.3                         8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c all          server-side, HTML-embedded scripting language (metapackage)
ii  php8.3-cli                     8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        command-line interpreter for the PHP scripting language
ii  php8.3-common                  8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        documentation, examples and common module for PHP
ii  php8.3-curl                    8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        CURL module for PHP
ii  php8.3-gd                      8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        GD module for PHP
ii  php8.3-ldap                    8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        LDAP module for PHP
ii  php8.3-mbstring                8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        MBSTRING module for PHP
ii  php8.3-mysql                   8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        MySQL module for PHP
ii  php8.3-opcache                 8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        Zend OpCache module for PHP
ii  php8.3-readline                8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        readline module for PHP
ii  php8.3-xml                     8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        DOM, SimpleXML, XML, and XSL module for PHP
ii  php8.3-zip                     8.3.21-1+0~20250509.62+debian12~1.gbpd2ac5c amd64        Zip module for PHP
root@wiki:/var/www/bookstack# sudo -u www-data git config core.fileMode false
root@wiki:/var/www/bookstack# sudo -u www-data git status
On branch release
Your branch is up to date with 'origin/release'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .env.bak
        .env.lmn-ldap
        composer.phar

nothing added to commit but untracked files present (use "git add" to track)

Thanks a lot for looking into my issue!

Jens-TGS avatar May 27 '25 19:05 Jens-TGS

Thanks @Jens-TGS again for the clear responses.

All looks okay there too! I was initially a bit suspicious of that different php-common package info, but looking at deb sury repo that looks fine.

I'm at a loss, not sure what further to (reasonably) check. At this stage, I might need to attempt replication of the same environment.

What architecture are you running here? Based upon being a proxmox based VM I'd assume standard x86_64? Just want to check though in case I'm assuming wrong.

ssddanbrown avatar May 27 '25 22:05 ssddanbrown

Hi @ssddanbrown,

thanks again for having a look on my issue!

Yes, it is standard x86_64. What do you need?

BR Jens

Jens-TGS avatar May 28 '25 04:05 Jens-TGS

Okay, I just tried to replicate this environment. Debian 12 LXC container on proxmox with deb sury repo using apache and mod-php, with the exact same dpkg -l | grep php output. No noticeable issues. Can't reproduce.

Makes me think it's more likely something specific to this environment and configuration. Not sure what to check next though.

ssddanbrown avatar May 30 '25 15:05 ssddanbrown

Dear Dan, thanks for replicating my environment and rolling out the tests. In the meantime I reverted my wiki VM back to a state of an older backup and updated the bookstack app again. Now everything is working again. Data loss is small, since the wiki was not used often in the affected time slot. If you are interested to narrow down the issue ether way, I might be able to provide you a backup of the VM including the issue.

Jens-TGS avatar Jun 06 '25 13:06 Jens-TGS

Dear Dan, I'm still facing this issue after each update. With 25.05.2 I did a complete re-installation of BookStack and restored a backup. Everything was working find then. But after updating to 25.07 today, again the start page looks like this:

@extends('layouts.tri') @section('body') @include('shelves.parts.list', ['shelves' => $shelves, 'view' => $view]) @stop @section('left') @include('home.parts.sidebar') @stop @section('right')
{{ trans('common.actions') }}

@if(user()->can('bookshelf-create-all')) [@icon('add') {{ trans('entities.shelves_new_action') }} ](https://wiki.my-page.de/%7B%7B%20url()@endif @include('entities.view-toggle', ['view' => $view, 'type' => 'bookshelves']) [@icon('tag') {{ trans('entities.tags_view_tags') }} ](https://wiki.tgs-freudenstadt.de/%7B%7B%20url('/tags')%20%7D%7D)@include('home.parts.expand-toggle', ['classes' => 'text-link', 'target' => '.entity-list.compact .entity-item-snippet', 'key' => 'home-details']) @include('common.dark-mode-toggle', ['classes' => 'icon-list-item text-link'])
@christophert 

Any suggestions?

Thanks a lot! Jens

Jens-TGS avatar Aug 01 '25 08:08 Jens-TGS

Hi @Jens-TGS, Do you have any active customizations? Anything in the /var/www/bookstack/themes folder?

Some of that shared code looks kind of strange, like markdown has been mixed with template code, and I'm not sure where that would have come from.

ssddanbrown avatar Aug 01 '25 14:08 ssddanbrown

Hi Dan,

thanks for your response. No, no active customizations. /var/www/bookstack/themesis empty except the .gitignore file. I also do have not much content in the wiki yet (mainly my IT stuff documentation).

My main question is: how do I get rid of this issue, if it seems, that the problem moves also, if I do a backup and restore in a fresh installation?

Any recommendations?

BR, Jens

Jens-TGS avatar Aug 02 '25 09:08 Jens-TGS

@Jens-TGS Generally I've seen this occur when there's either file permission issues or php extension & extension lib version mismatches.

There's some really strange things though in both examples of what you have shared, which I would not expect at all. For example, I don't know why there's the @christophert text, since that string does not appear in the repo, and is the username of someone who has previously contributed to the project.

ssddanbrown avatar Aug 04 '25 14:08 ssddanbrown

@ssddanbrown That sounds really weired. Are you interested in narrowing down the issue or is your recommandation again a clean install and restoring a backup?

Jens-TGS avatar Aug 05 '25 19:08 Jens-TGS

@ssddanbrown Any updates on this issue in the meantime? Still not able to update to a newer version here .. :-(

Jens-TGS avatar Sep 28 '25 14:09 Jens-TGS

@Jens-TGS No, sorry.

Feel free to send a link to a VM backup file (where the issue exists) to my email (Shown when viewing my GitHub profile).

ssddanbrown avatar Oct 05 '25 14:10 ssddanbrown

@ssddanbrown Thanks a lot for providing this opportunity. I just wanted to create the VM backup file for you. Installed bookstack version was 25.05.2. I did take a snapshot and tried to do the latest update to 25.07.3 to see, if my update issue is still reproducible. And: it is not. In the meantime I also rolled back to my snapshot and gave the new update process with bookstack-system-cli a chance and also this is working. Did you do any changes which could explain, that my issue seems to be gone in the meantime?

Jens-TGS avatar Oct 06 '25 02:10 Jens-TGS

@Jens-TGS Good to hear things are working! No, Can't think of any changes which would affect this.

My gut instinct is that there was a bug or something odd/off in regards to a specific dependency in your environment, which has since been patched/changed/updated (or a process was using an old library in memory maybe).

ssddanbrown avatar Oct 13 '25 12:10 ssddanbrown