Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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

  • Options
    charrondevcharrondev Developer Lead (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.

  • Options

    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

  • Options

    I have the same problem with clean install and converted database.

    Ich did all the settings in the config.php as mentioned above, but the error persists.

    What can I do?

    Thanks for help...


  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Everytime you disable the rich editor, you have to add the input formatter setting in the config.php

    Mit einem bereits gespeicherten Entwurf hast du aber keine Chance, der ist "verloren" und den musst du entweder löschen oder das Format in der Datenbank anpassen

  • Options

    Thanks... changing the "rich" setting in the config.php is not enough, I did it and failed.

    After editing the "config-defaults.php" (3 entries) the comments work as they should. I changed the values to "HTML".

    SOLVED.

    P.S.: Is there a possibility to use the Rich-Editor in the future?

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    The rich editor is used on this page and it is the editor that the Vanilla developers favor right now. So you can use it already, though there are reasons why you might not like to do it. You can follow the development of Vanilla on GitHub and see if a) there is already an issue for something that you would say is a reason not to use that editor and b) get notified when that issue has received a fix.

  • Options
    AoleeAolee Hobbyist & Coder ✭✭

    Many thanks for this guide! I went to panic after I enable disabled the Rich Editor :D had to put back the lines in config

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


  • Options
    vinwinvinwin Ho Chi Minh New

    Thanks... changing the "rich" setting in the config.php is not enough, I did it and failed.

  • Options

    I inherited and upgraded a vanilla forum, and the only options for posting format were rich or text, and rich produces the error and text is too limited. None of the above fixed the "JSON could not be converted into quill operations" for me. 

    In case anyone runs into same problem, this puts a working HTML editor (doesn't fix Rich):

    1. Change $Configuration['EnabledPlugins']['editor'] setting from false to true in /conf/config.php

    // EnabledPlugins

    $Configuration['EnabledPlugins']['editor'] = true;


    2. Deleted everything in /cache/ 


    3. In the admin dashboard section of the site, hard browser reload on the Posting Settings page /vanilla/settings/posting


    4. Choose HTML or Wysiwyg 

Sign In or Register to comment.