A guide to ... JSON could not be converted into quill operations

Vanilla 2.8 (supposed issue)

PHP version or Server type/config seems to be irrelevant

file location vanilla-core-2-8/library/Vanilla/Formatting/Quill/Parser.php

/**
 * Attempt to convert a JSON string into an array of operations.
 *
 * @param string $json
 *
 * @return array
 * @throws FormattingException If valid operations could not be produced.
 */
public static function jsonToOperations(string $json): array {
    $operations = json_decode($json, true);

    if (json_last_error() !== JSON_ERROR_NONE || !is_array($operations)) {
        throw new FormattingException("JSON could not be converted into quill operations.\n $json");
    }
    return $operations;
}

A Guide to Probably Help Others

2.8 introduced a new editor, and with it a new editor format.

On Fresh install or upgrade of existing forum one/two very important settings in your /conf/config.php will change to

$Configuration['Garden']['InputFormatter'] = 'Rich'; //Html, Markdown
$Configuration['Garden']['MobileInputFormatter'] = 'Rich'; //Html, Markdown

That is the same settings now in /conf/config-defaults.php


What the above means is that, your new default format is now 'Rich'. (THIS IS SOMETHING TO EASILY FORGET OR NOT REALIZE)

10 to 1, your existing discussions already have a format such as (Html, WYSIWYG, Markdown, BBCode, Text), these will have no problem because they will not evoke Rich Editor, and have nothing to do with the Rich Format.

  1. BUT new discussions will take the "Rich" format setting, as per your default setting. Now, you must be using an editor that can send the required valid JSON to the DataBase. Or else you will get the error we are talking about.
  2. If you change InputFormatter to Html or Markdown in /conf/config.php . The entire line is gutted when you disable Rich Editor. And therefore InputFormatter setting will be derived from /conf/config-defaults.php which has it as "Rich".
  3. And so, all editors (Rich Editor being disabled) you use now will fail when creating new discussions because they cannot produce the required valid JSON.
  4. If you have InputFormatter set to anything but "Rich", and you re-enable the Rich Editor, beware, that InputFormatter will be reset to "Rich". If you disable this Rich Editor, be sure to reset that InputFormatter setting in config.php, and best to reset that in config-defaults.php as well.
  5. If you will not be using the Rich-Editor plugin, disable it, delete its folder, and you must explicitly set the InputFormatter in both config.php and config-defaults.php


Hope this helps some poor traveler.

Cheers.

Comments

  • charrondevcharrondev Application Developer (PHP, JS) Montreal Vanilla Staff

    Thanks for the post. We've actually rolled back the config default changes which will go out in the next patch release do some issues this caused with people that didn't say, have a mobile input formatter set.

    I think we'll be moving to an addon config default that's only present if rich editor is enabled which will resolve this.

  • Here is another thing to consider. A rather very important aspect of vanilla's "Quick Posting" fails with Rich Editor.

    You can test it on this here. The body part is unrecognizable to Rich Editor. The editor fails to load/show.

    Wait 2 seconds, auto-save of draft sends that data and boom:

    "JSON could not be converted into quill operations. Wherefore_art_thou_not_Romeo"

    https://open.vanillaforums.com/post/discussion/Feedback?name=Hello_Rich_Editor&body=Wherefore_art_thou_not_Romeo

Sign In or Register to comment.