I ran across an error in a Knowledgetree plugin while setting it up for a client. For those who don't know, Knowledgetree is an open source document management system.
Two plugins were installed, the Wemag TreeBrowse plugin, and the Wemag Online Document Viewer.
The Treeview plugin was installed first, and worked as expected for several days. However, when the Online Document Viewer was installed, Knowledgetree immediately failed with an error:
Fatal error: Class 'KTFolderAction' not found in /usr/share/knowledgetree-ce/plugins/WemagTreeBrowsePlugin/WemagTreeBrowsePlugin.php on line 34
Note the error appears to be in the TreeBrowse plugin, but only appears once the Online Document Viewer is installed.
Although I haven't analyzed the code execution path, or the complete list of loaded libraries and included files, it appears that these two plugins load in such a way as the function include files are not loaded in time for the TreeBrowse plugin to use them when both are installed.
The missing function - KTFolderAction - is defined in a function library that comes with Knowledgetree, in the standard library directory:
The easiest solution is to include this file within the WemagTreeBrowsePlugin.php file prior to the point where the function is needed.
In the WemagTreeBrowsePlugin.php file, starting on line 26, is a series of library include statements:
require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); require_once(KT_LIB_DIR . '/browse/PartialQuery.inc.php'); require_once(KT_LIB_DIR . '/documentmanagement/Document.inc');
Add in an extra one at the end, so that the series looks like this:
require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); require_once(KT_LIB_DIR . '/browse/PartialQuery.inc.php'); require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); require_once(KT_LIB_DIR . '/actions/folderaction.inc.php');
This fixes the missing function error, and allows you to login. Both plugins also work properly, so no functionality is broken by this solution.