qky666 / dokuwiki-plugin-odtplus2dw

Import different files (odt, doc, docx...) in a dokuwiki page
3 stars 3 forks source link

Error: Undefined constant "XSLTProcessor" #8

Closed Stikus closed 8 months ago

Stikus commented 8 months ago

Hello @qky666 , I understand that plugin development have stopped years ago, but it was working fine for me.

But after update to php 8+ I got this error: image

2024-02-14 10:19:01     /opt/www/wiki.cspfmba.ru/lib/plugins/odtplus2dw/action.php(214) Error: Undefined constant "XSLTProcessor"                    
  #0 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(126): action_plugin_odtplus2dw->_odtplus2dw()                                        
  #1 /opt/www/wiki/inc/Extension/EventHandler.php(80): action_plugin_odtplus2dw->_parser(Object(dokuwiki\Extension\Event), Array)         
  #2 /opt/www/wiki/inc/Extension/Event.php(75): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'BEFORE')
  #3 /opt/www/wiki/inc/ActionRouter.php(83): dokuwiki\Extension\Event->advise_before()                                                    
  #4 /opt/www/wiki/inc/ActionRouter.php(49): dokuwiki\ActionRouter->setupAction('odtplus2dw')                                             
  #5 /opt/www/wiki/inc/ActionRouter.php(62): dokuwiki\ActionRouter->__construct()                                                         
  #6 /opt/www/wiki/inc/actions.php(19): dokuwiki\ActionRouter::getInstance(true)                                                          
  #7 /opt/www/wiki/doku.php(131): act_dispatch()                                                                                          
  #8 {main}          

According to code https://github.com/qky666/dokuwiki-plugin-odtplus2dw/blob/master/action.php#L214-L216:

    // Class Control
    if ( ! class_exists( XSLTProcessor ) ) return $this->_msg('er_class_xsltProcessor');
    if ( ! class_exists( ZipArchive ) ) return $this->_msg('er_class_zipArchive');
    if ( ! class_exists( DOMDocument ) ) return $this->_msg('er_class_domDocument');
    // Create instance of needed class
    $this->XSLT = new XSLTProcessor;
    $this->ZIP  = new ZipArchive;
    $this->XSL  = new DOMDocument;
    $this->XML  = new DOMDocument;

and my tests - small edition - adding quotes to XSLTProcessor, ZipArchive and DOMDocument in class_exists statement fixes the problem.

Can you add this fix? Without it, I have to manually patch our file.

qky666 commented 8 months ago

Hello @Stikus , I'm not working in this plugin (or even using Dokuwiki) anymore, but I don't mind making changes if they are useful to anyone. I hope the problem is fixed now.