crazy-max / docker-dokuwiki

DokuWiki Docker image
MIT License
43 stars 19 forks source link

Plugins partially broken #26

Closed apollo13 closed 3 years ago

apollo13 commented 3 years ago

Behaviour

Steps to reproduce this issue

  1. Install the searchindex plugin
  2. Try to reindex

Expected behaviour

The ui should update nicely and reindex all pages

Actual behaviour

Hangs at "Searching pages" and the developer console shows a 500 error. Errorlogs show:

2020/10/20 15:11:49 [error] 530#530: *75 FastCGI sent in stderr: "PHP message: PHP Warning:  require_once(//inc/init.php): failed to open stream: No such file or directory in /data/plugins/searchindex/ajax.php on line 17PHP message: PHP Fatal error:  require_once(): Failed opening required '//inc/init.php' (include_path='.:/usr/share/php7') in /data/plugins/searchindex/ajax.php on line 17" while reading response header from upstream

The reason for this is that searchindex (and maybe other plugins) construct DOKU_INC like this: https://github.com/splitbrain/dokuwiki-plugin-searchindex/blob/32e56a59996ea3a10b3a70f0239fc13d58f1174b/ajax.php#L16

This breaks down when the plugins are symlinked into the data directory. Any ideas on how to improve this?

apollo13 commented 3 years ago

I managed to fix this in a custom docker image by adding /var/www/fixes.php with this content:

<?php

if(!defined('DOKU_INC')) define('DOKU_INC', '/var/www/');

and adding a 02-fixes.sh for cont-init.d doing the following:

#!/usr/bin/with-contenv sh

# PHP
echo "Setting PHP INI configuration..."
sed -i "s|auto_prepend_file.*|auto_prepend_file = /var/www/fixes.php|g" /etc/php7/php.ini

This way the fixes.php is loaded for every request and DOKU_INC will always be defined. This way plugins do not have to guess where it is.

wgordon17 commented 3 years ago

@crazy-max Any chance you can validate if this is something you could include? I'm seeing error messages about DOKU_INC as well

crazy-max commented 3 years ago

@apollo13 @wgordon17 Very sorry for the delay, can you test with crazymax/dokuwiki:edge? Thanks!

wgordon17 commented 3 years ago

@crazy-max That unfortunately hasn't fixed the issue for me. My issue seems specific to the Dokuwiki Bootstrap3 template.

I am currently using this as a workaround: https://github.com/giterlizzi/dokuwiki-template-bootstrap3/blob/master/css.php#L18-L22

But I'm thinking I might actually just be better served by submitting a PR to the Bootstrap3 template for this specific path, similar to how they've done it for other Docker images: https://github.com/giterlizzi/dokuwiki-template-bootstrap3/blob/master/css.php#L27-L30

crazy-max commented 3 years ago

@wgordon17 Thanks for your feedback. Yeah it looks like the fix of @apollo13 is the best in this kind of situation. I will make the necessary changes.

crazy-max commented 3 years ago

Ok should be fixed now.

apollo13 commented 3 years ago

@crazy-max While testing for #25 I think you broken the edge repo with the latest commit in here:

2021/02/20 10:34:48 [error] 529#529: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0PHP message: PHP Fatal error:  Unknown: Failed opening required '/var/www/preload.php' (include_path='.:/usr/share/php7') in Unknown on line 0" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm7.sock:", host: "localhost:8000"

preload.php is in /var/www/inc in my container at least.

crazy-max commented 3 years ago

@apollo13 Sorry my bad.. I've triggered a new release to fix that: https://github.com/crazy-max/docker-dokuwiki/runs/1941489326?check_suite_focus=true

apollo13 commented 3 years ago

Works great now, thanks!