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'];
    }
  }
CommentFileSizeAuthor
#2 2753747-undefined-index-errors-2.patch681 bytesakalata
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MaskOta created an issue. See original summary.

akalata’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
Status: Active » Needs review
FileSize
681 bytes

Here's a patch against the dev branch. Incorporates the suggested code from #1, adding an explicit return FALSE if wordcount settings are not found.

kevinquillen’s picture

I 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.

kevinquillen’s picture

Assigned: Unassigned » kevinquillen

  • kevinquillen committed 89f3c31 on 8.x-1.x authored by akalata
    Issue #2753747 by akalata, kevinquillen: Undefined index for each text...
kevinquillen’s picture

Status: Needs review » Fixed
kevinquillen’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.