linuxserver / docker-dokuwiki

GNU General Public License v3.0
110 stars 24 forks source link

Issue 27: store search index outside of container and set absolute (default) path for 'savedir' #30

Closed bh1428 closed 3 years ago

bh1428 commented 3 years ago

Description:

The search index is created inside the container: when the container is upgraded the index will be removed and search is broken. If you try to rebuild the index using the Searchindex Manager you get another error: (existing) directories are not found and as a consequence you cannot rebuild the index. This PR fixes both issues and thereby closes #27.

Benefits of this PR and context:

This fixes an outstanding bug and closes #27.

How Has This Been Tested?

The change has been tested by:

Source / References:

See issue #27.

LinuxServer-CI commented 3 years ago

I am a bot, here are the test results for this PR: https://ci-tests.linuxserver.io/lspipepr/dokuwiki/2020-07-29-pkg-90a2de65-pr-30/index.html https://ci-tests.linuxserver.io/lspipepr/dokuwiki/2020-07-29-pkg-90a2de65-pr-30/shellcheck-result.xml

github-actions[bot] commented 3 years ago

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aptalca commented 3 years ago

Sorry I keep putting this off because I have a question about the PR, but haven't asked it yet.

What's the deal with the savedir setting? Shouldn't it just work since we're symlinking?

bh1428 commented 3 years ago

First of all, I am not a Docker and/or PHP specialist, so my knowledge here is limited, but from what I understand...

Yes we are indeed symlinking. However for some reason dokuwiki seems to use a function to retrieve real absolute paths in inc/init.php: function init_paths -> init_path -> fullpath. From the comments I get that fullpath behaves similary to the PHP's realpath (http://php.net/manual/en/function.realpath.php#75992)) and that seems a way to get the real absolute path.

When the savedir is relative (./data), the SearchIndex Manager plugin does not work because it finds the savedir by walking up the tree from its own absolute path (/config/dokuwiki/lib/plugins/searchindex). In other words savedir should be at /config/dokuwiki/data. That is not entirely wrong (our wiki pages are there), however that location only contains those parts of the savedir we explicitly placed outside the container (for example the cache subdirectory is not there and that's a problem for the SearchIndex Manager plugin).

If you change savedir to the absolute path inside the container (i.e. /app/dokuwiki/data) the location of the SearchIndex Manager plugin is no longer used and the plugin now finds the cache directory: you can rebuild the search index. My set 'savedir' to path in container patch changes the savedir to the absolute path when the container is started and the savedir path is still the default path (thereby automating the manual fix which is adapting the savedir in the configuration). This makes the SearchIndex Manager plugin work and still keeps the cache directory inside the container (I like that: upgrading the container means cleaning the cache).