evnix / codowik

now convert dokuwiki engine into a professional wiki with codowik template
13 stars 16 forks source link

Fix PHP Fatal Error #19

Open MachX428 opened 3 years ago

MachX428 commented 3 years ago

Template does not work and makes Dokuwiki unusable. The following error can be found in log/nginx/error.log:

"PHP message: PHP Fatal error: Call to undefined function tpl_js() in /config/dokuwiki/lib/tpl/codowik/main.php:36"

I believe this is due to a bad merge. Fixed the issue and now everything works. Tested on Release 2020-07-29 "Hogfather".

kotadr commented 1 year ago

To solve the problem, you need to add the definition of the function to the main.php file:

/**
 * Returns HTML string with script tag
 * @param  string $filename
 * @return string
 */
function tpl_js($filename)
{
    $filepath = DOKU_TPL . 'js' . DIRECTORY_SEPARATOR . $filename;
    return "<script type=\"application/javascript\" src=\"{$filepath}\"></script>";
}
MachX428 commented 1 year ago

Hello @kotadr . Thank you for the note! Just to clarify, are you saying you are still having the PHP Fatal Error problem AFTER applying my changes? After my changes, I no longer had them. If I remember correctly (it's been about a year and half since I looked at this), the problem here appeared when the last commit (0916d3b) which merged in a PR which pulled some functions back into main.php which on previous commit (93b77a8) had just been moved out of main.php into main.js. With this merge, these functions now existed in both places. Since all of these merges/commits happened the same day, I think it was just a case of each PR working independently, but merging them all together caused a problem because those functions were now duplicated in different places. Anyway, my "fix" (which was just really correcting the merge) caused the problem to go away for me, as the functions now existed only in main.js. I have been running with my mods for the past year and a half without any issues. I even have them deployed on a friend's instance and he is also having no problems. So I just want to double check - are you saying that my changes did not work for you and you are still getting the PHPFatalError? Thanks again for taking the time!