1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* DokuWiki Plugin prosemirror (Action Component) |
4
|
|
|
* |
5
|
|
|
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html |
6
|
|
|
* @author Andreas Gohr <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
// must be run within Dokuwiki |
10
|
|
|
use dokuwiki\plugin\prosemirror\parser\SyntaxTreeBuilder; |
11
|
|
|
|
12
|
|
|
if (!defined('DOKU_INC')) { |
13
|
|
|
die(); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
class action_plugin_prosemirror_parser extends DokuWiki_Action_Plugin |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Registers a callback function for a given event |
21
|
|
|
* |
22
|
|
|
* @param Doku_Event_Handler $controller DokuWiki's event controller object |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function register(Doku_Event_Handler $controller) |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_preprocess'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* [Custom event handler which performs action] |
33
|
|
|
* |
34
|
|
|
* Triggered by: ACTION_ACT_PREPROCESS |
35
|
|
|
* |
36
|
|
|
* @param Doku_Event $event event object by reference |
37
|
|
|
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this |
38
|
|
|
* handler was registered] |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function handle_preprocess(Doku_Event $event, $param) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
global $TEXT, $INPUT; |
45
|
|
|
if ($INPUT->server->str('REQUEST_METHOD') !== 'POST' |
46
|
|
|
|| !in_array($event->data, ['save', 'preview']) |
47
|
|
|
|| !$INPUT->post->has('prosemirror_json') |
48
|
|
|
) { |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$unparsedJSON = $INPUT->post->str('prosemirror_json'); |
53
|
|
|
if (json_decode($unparsedJSON, true) === null) { |
54
|
|
|
msg('Error decoding prosemirror data', -1); |
|
|
|
|
55
|
|
|
return; |
56
|
|
|
} |
57
|
|
|
try { |
58
|
|
|
$rootNode = SyntaxTreeBuilder::parseJsonIntoTree($unparsedJSON); |
59
|
|
|
} catch (Throwable $e) { |
60
|
|
|
$errorMsg = 'Parsing the data provided by the WYSIWYG editor failed with message: ' . hsc($e->getMessage()); |
|
|
|
|
61
|
|
|
/** @var helper_plugin_sentry $sentry */ |
62
|
|
|
$sentry = plugin_load('helper', 'sentry'); |
|
|
|
|
63
|
|
|
if ($sentry) { |
|
|
|
|
64
|
|
|
$sentry->logException($e); |
65
|
|
|
$errorMsg .= ' Error has been logged to Sentry.'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
msg($errorMsg, -1); |
69
|
|
|
return; |
70
|
|
|
} |
71
|
|
|
$syntax = $rootNode->toSyntax(); |
72
|
|
|
if (!empty($syntax)) { |
73
|
|
|
$TEXT = $syntax; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
// vim:ts=4:sw=4:et: |
79
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths