TheCadien / SuluNewsBundle

Simple News Bundle for Sulu 2 CMS
MIT License
14 stars 12 forks source link

Unable to edit SEO tab #43

Open joselaurens opened 1 year ago

joselaurens commented 1 year ago

I install the Bundle on Sulu 2.5, configure and can start using it. But when accessing the SEO tab, it doesn't allow me to edit any fields. When writing in any field, I get this error that I don't understand.

error_seo_tab

Uncaught TypeError: e is undefined
    set index.js:101
    set ResourceStore.js:274
    MobX 2
    change ResourceStore.js:294
    MobX 2
    change ResourceFormStore.js:276
    handleChange Form.js:93
    handleChange Field.js:76
    handleChange Input.js:45
    React 11
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
index.js:101:4

Line 101 is method

api.set = function set (obj, pointer, value) {
    var refTokens = Array.isArray(pointer) ? pointer : api.parse(pointer),
      nextTok = refTokens[0];

    if (refTokens.length === 0) {
      throw Error('Can not set the root object');
    }

    for (var i = 0; i < refTokens.length - 1; ++i) {
        var tok = refTokens[i];
        if (typeof tok !== 'string' && typeof tok !== 'number') {
          tok = String(tok)
        }
        if (tok === "__proto__" || tok === "constructor" || tok === "prototype") {
            continue
        }
        if (tok === '-' && Array.isArray(obj)) {
          tok = obj.length;
        }
        nextTok = refTokens[i + 1];

        if (!(tok in obj)) {
            if (nextTok.match(/^(\d+|-)$/)) {
                obj[tok] = [];
            } else {
                obj[tok] = {};
            }
        }
        obj = obj[tok];
    }
    if (nextTok === '-' && Array.isArray(obj)) {
      nextTok = obj.length;
    }
    obj[nextTok] = value;
    return this;
};

Composer requires are

"require": {
        "php": "^8.1",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "dantleech/phpcr-migrations-bundle": "^1.3",
        "doctrine/doctrine-bundle": "^2.5",
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "friendsofsymfony/http-cache-bundle": "^2.10.1",
        "handcraftedinthealps/zendsearch": "^2.1",
        "jackalope/jackalope-doctrine-dbal": "^1.7",
        "scheb/2fa-bundle": "^6.1",
        "scheb/2fa-email": "^6.1",
        "scheb/2fa-trusted-device": "^6.1",
        "sulu/sulu": "~2.5.7",
        "symfony/config": "^6.2",
        "symfony/dotenv": "^6.2",
        "symfony/flex": "^1.17 || ^2.0",
        "symfony/framework-bundle": "^6.2",
        "symfony/mailer": "^6.2",
        "symfony/monolog-bridge": "^6.2",
        "symfony/monolog-bundle": "^3.4",
        "symfony/runtime": "^6.2",
        "symfony/security-bundle": "^6.2",
        "symfony/twig-bundle": "^6.2",
        "thecadien/sulu-news-bundle": "^1.3"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^3.9",
        "jangregor/phpstan-prophecy": "^1.0",
        "phpcr/phpcr-shell": "^1.4",
        "phpspec/prophecy-phpunit": "^2.0",
        "phpstan/extension-installer": "^1.1",
        "phpstan/phpstan": "^1.4",
        "phpstan/phpstan-doctrine": "^1.2",
        "phpstan/phpstan-phpunit": "^1.0",
        "phpstan/phpstan-symfony": "^1.1",
        "phpstan/phpstan-webmozart-assert": "^1.0",
        "phpunit/phpunit": "^9.5",
        "rector/rector": "^0.15.1",
        "sulu/sulu-rector": "^0.1.3",
        "symfony/browser-kit": "^6.2",
        "symfony/css-selector": "^6.2",
        "symfony/debug-bundle": "^6.2",
        "symfony/error-handler": "^6.2",
        "symfony/phpunit-bridge": "^6.2",
        "symfony/thanks": "^1.2",
        "symfony/web-profiler-bundle": "^6.2",
        "thecodingmachine/phpstan-strict-rules": "^1.0"
    },

This also happened to me on a Sulu 2.4 installation with SuluNewsBundle version 1.2.0.

manuxi commented 1 year ago

Same here...

TheCadien commented 1 year ago

@manuxi can confirm that we had here a bug. At the moment, however, I unfortunately lack the time to repoduce exactly why this arises.

alexander-schranz commented 1 year ago

I would say this is a serialization issue in the bundle. Empty array maybe converted into [] instead of into a empty object {} and so the JSON Pointer not working:

Make sure the bundle return:

{
    "ext": {
          "seo": {} // <-- if this is [] it could be the problem of the issue
    }
}