Skip to content

Commit

Permalink
Ensure DOKU_INC is always right using an auto_prepend_file
Browse files Browse the repository at this point in the history
This is basically the same fix as bitnami/containers#12535

Plugins or template may have their own entry points. Eg. the sprintdoc
template's svg.php

Those entrypoints usually start with something like:

```
if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
require_once(DOKU_INC . 'inc/init.php');
```

Since plugins are installed in the volume, __DIR__ will point to the
wrong location. By predefining DOKU_INC before any other code runs, this
can be avoided.
  • Loading branch information
splitbrain committed Jun 24, 2024
1 parent 9a12b5c commit 33a8947
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions root/usr/local/etc/php/conf.d/dokuwiki.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ post_max_size = ${PHP_UPLOADLIMIT}
upload_max_filesize = ${PHP_UPLOADLIMIT}
memory_limit = ${PHP_MEMORYLIMIT}
date.timezone = ${PHP_TIMEZONE}
auto_prepend_file = /var/www/html/.autoprepend.php
7 changes: 7 additions & 0 deletions root/var/www/html/.autoprepend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* This file is automatically loaded by PHP before any other code. This ensures that DOKU_INC is
* is always pointing to the correct location within the container, even when the entry point is
* a plugin.
*/
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
2 changes: 1 addition & 1 deletion root/var/www/html/health.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

define('DOKU_UNITTEST', 1);
define('DOKU_INC', __DIR__ . '/');
if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');

header('Content-Type: text/plain; charset=utf-8');
try {
Expand Down

0 comments on commit 33a8947

Please sign in to comment.