Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As soon as i enabled the module i got this error for each text format i had enabled when editing a node.
Notice: Undefined index: wordcount in Drupal\ckwordcount\Plugin\CKEditorPlugin\Wordcount->isEnabled() (line 52 of modules/ckwordcount/src/Plugin/CKEditorPlugin/Wordcount.php).
This seemed to solve it but maybe there is a better way to do it:
public function isEnabled(Editor $editor) {
$plugins = $editor->getSettings()['plugins'];
if (isset($plugins['wordcount'])) {
return $editor->getSettings()['plugins']['wordcount']['enable'];
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | 2753747-undefined-index-errors-2.patch | 681 bytes | akalata |
Comments
Comment #2
akalata CreditAttribution: akalata commentedHere's a patch against the dev branch. Incorporates the suggested code from #1, adding an explicit return FALSE if
wordcount
settings are not found.Comment #3
kevinquillen CreditAttribution: kevinquillen at Velir commentedI see no issue with this offhand. Since there is no UI button to drag to the toolbar, the plugin is technically enabled, but also must be enabled for the format (so it isn't forced onto every applicable filter).
Instead of wrapping the last return false, I left out the
else
.Comment #4
kevinquillen CreditAttribution: kevinquillen at Velir commentedComment #6
kevinquillen CreditAttribution: kevinquillen at Velir commentedComment #7
kevinquillen CreditAttribution: kevinquillen at Velir commented