Error 500 when trying to save any page #3336

Closed
opened 2026-02-05 06:23:40 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @AlbanDCX on GitHub (Nov 9, 2022).

Describe the Bug

Saving a page makes a Post request returning a 500 reponse because of uninitailized property.
The page is not saved
In laravel.log the stak trace start with:
production.ERROR: Typed property DOMDocument::$documentElement must not be accessed before initialization {"userId":3,"exception":"[object] (Error(code: 0): Typed property DOMDocument::$documentElement must not be accessed before initialization at /var/www/html/bookstack/app/Entities/Tools/PageContent.php:181)

Steps to Reproduce

  1. go a page as admin, or editor role
  2. edit it
  3. click on save

Expected Behaviour

The page should be saved without an error

Screenshots or Additional Context

No response

Browser Details

Firefox 106.0.5

Exact BookStack Version

v22.10.2

PHP Version

8.1

Hosting Environment

Debian 11 + nginx

Originally created by @AlbanDCX on GitHub (Nov 9, 2022). ### Describe the Bug Saving a page makes a Post request returning a 500 reponse because of uninitailized property. The page is not saved In laravel.log the stak trace start with: production.ERROR: Typed property DOMDocument::$documentElement must not be accessed before initialization {"userId":3,"exception":"[object] (Error(code: 0): Typed property DOMDocument::$documentElement must not be accessed before initialization at /var/www/html/bookstack/app/Entities/Tools/PageContent.php:181) ### Steps to Reproduce 1. go a page as admin, or editor role 2. edit it 3. click on save ### Expected Behaviour The page should be saved without an error ### Screenshots or Additional Context _No response_ ### Browser Details Firefox 106.0.5 ### Exact BookStack Version v22.10.2 ### PHP Version 8.1 ### Hosting Environment Debian 11 + nginx
OVERLORD added the 🐛 Bug label 2026-02-05 06:23:40 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Nov 9, 2022):

Hi @AlbanDCX,

Can you confirm if this only happens on certain page content, or does it occur all the time, regardless of page content being saved? If it's dependant on content, could you share an example?

Also, could you confirm the exact output of running php -v on the command line on the system used to host BookStack.

@ssddanbrown commented on GitHub (Nov 9, 2022): Hi @AlbanDCX, Can you confirm if this only happens on certain page content, or does it occur all the time, regardless of page content being saved? If it's dependant on content, could you share an example? Also, could you confirm the exact output of running `php -v` on the command line on the system used to host BookStack.
Author
Owner

@AlbanDCX commented on GitHub (Nov 9, 2022):

Hi,

This occurs on every page, even with a single word

php -v

PHP 8.1.12 (cli) (built: Oct 28 2022 18:32:13) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies

@AlbanDCX commented on GitHub (Nov 9, 2022): Hi, This occurs on every page, even with a single word php -v PHP 8.1.12 (cli) (built: Oct 28 2022 18:32:13) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.12, Copyright (c) Zend Technologies with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies
Author
Owner

@ssddanbrown commented on GitHub (Nov 9, 2022):

@AlbanDCX Thanks for the info. Since you're on php8.1, are you using the deb.sury packages to get that?

Also, would you be able to share your nginx config?

@ssddanbrown commented on GitHub (Nov 9, 2022): @AlbanDCX Thanks for the info. Since you're on php8.1, are you using the [deb.sury](https://deb.sury.org/) packages to get that? Also, would you be able to share your nginx config?
Author
Owner

@AlbanDCX commented on GitHub (Nov 9, 2022):

Hi,

Packages come indeed from deb.sury
Here is the nginx conf

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        index index.php index.html

        server_name docs.docaxess.com;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
                 fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }

}




server {

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html/bookstack/public;
        index index.php index.html
        server_name docs.docaxess.com; # managed by Certbot


        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
                 fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }



        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/docs.docaxess.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/docs.docaxess.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
        if ($host = docs.docaxess.com) {
                return 301 https://$host$request_uri;
        } # managed by Certbot


        listen 80 ;
        listen [::]:80 ;
        server_name docs.docaxess.com;
        return 404; # managed by Certbot


}

``

@AlbanDCX commented on GitHub (Nov 9, 2022): Hi, Packages come indeed from deb.sury Here is the nginx conf ``` server { listen 80 default_server; listen [::]:80 default_server; index index.php index.html server_name docs.docaxess.com; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.1-fpm.sock; } } server { # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html/bookstack/public; index index.php index.html server_name docs.docaxess.com; # managed by Certbot location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.1-fpm.sock; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/docs.docaxess.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/docs.docaxess.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = docs.docaxess.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80 ; listen [::]:80 ; server_name docs.docaxess.com; return 404; # managed by Certbot } ``` ``
Author
Owner

@ssddanbrown commented on GitHub (Nov 10, 2022):

Hi @AlbanDCX,
I just created a replica debian 11 setup with the exact same PHP version and I used your nginx config as a basis, but could not reproduce this issue and saving worked fine.

Not really sure what's going on at this stage.
Have attempted a couple things to attempt to force this error without success.

Can only find one other recent reference to something similar, and it sounds like it was a case of updating from an old php version, and having mixed packages.
Did you install another version of PHP previously on this system before installing PHP8.1? Could make sense that requirements get mismatched across different installed versions.

@ssddanbrown commented on GitHub (Nov 10, 2022): Hi @AlbanDCX, I just created a replica debian 11 setup with the exact same PHP version and I used your nginx config as a basis, but could not reproduce this issue and saving worked fine. Not really sure what's going on at this stage. Have attempted a couple things to attempt to force this error without success. Can only find one other recent reference to something similar, and it sounds like it was a case of updating from an old php version, and having mixed packages. Did you install another version of PHP previously on this system before installing PHP8.1? Could make sense that requirements get mismatched across different installed versions.
Author
Owner

@AlbanDCX commented on GitHub (Nov 10, 2022):

Hi Dan,

Thx for the clue: it's working now.
I removed php and all its packages and reinstalled them, I had some packages not prefixed by "php8.1"

Best,
Alban

@AlbanDCX commented on GitHub (Nov 10, 2022): Hi Dan, Thx for the clue: it's working now. I removed php and all its packages and reinstalled them, I had some packages not prefixed by "php8.1" Best, Alban
Author
Owner

@ssddanbrown commented on GitHub (Nov 10, 2022):

Great! Good to hear things are now working. Will therefore close this off.

@ssddanbrown commented on GitHub (Nov 10, 2022): Great! Good to hear things are now working. Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3336