Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError array_flip(): Argument #1 ($array) must be of type array, null given #359

Open
kbergha opened this issue Jan 29, 2025 · 0 comments
Labels

Comments

@kbergha
Copy link

kbergha commented Jan 29, 2025

Description

Hi. I'm getting a type error when trying to edit a single that has a CKE-field.
It's probably related to the setting for "who should see the source button", which I have turned off for everyone.

The field has a custom CKE config, and a custom HTML Purifier config (not sure if these are relevant).

After removing the field, the editing works as expected when adding other field types, like plain text.

Steps to reproduce

CKE config:

Image

Field setup:

Image

Entry type setup:

Image

HTML-purifier config (Default.json):

{
  "AutoFormat.Linkify": true,
  "AutoFormat.RemoveEmpty": true,
  "AutoFormat.RemoveEmpty.RemoveNbsp": true,
  "HTML.Allowed": "a[href],p,ul,ol,li,h2,h3,h4"
}

Then, trying to edit an existing single:

Image

Stacktrace:

TypeError: array_flip(): Argument #1 ($array) must be of type array, null given in /app/vendor/craftcms/ckeditor/src/Field.php:1208
Stack trace:
#0 /app/vendor/craftcms/ckeditor/src/Field.php(1208): array_flip(NULL)
#1 /app/vendor/craftcms/ckeditor/src/Field.php(891): craft\ckeditor\Field->isSourceEditingAllowed(Object(craft\elements\User))
#2 /app/vendor/craftcms/cms/src/base/Field.php(708): craft\ckeditor\Field->inputHtml(NULL, Object(craft\elements\Entry), false)
#3 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(406): craft\base\Field->getInputHtml(NULL, Object(craft\elements\Entry))
#4 /app/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(365): craft\fieldlayoutelements\CustomField->inputHtml(Object(craft\elements\Entry), false)
#5 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(357): craft\fieldlayoutelements\BaseField->formHtml(Object(craft\elements\Entry), false)
#6 /app/vendor/craftcms/cms/src/web/View.php(1885): craft\fieldlayoutelements\CustomField->craft\fieldlayoutelements\{closure}()
#7 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(356): craft\web\View->namespaceInputs(Object(Closure), 'fields')
#8 /app/vendor/craftcms/cms/src/models/FieldLayout.php(1013): craft\fieldlayoutelements\CustomField->formHtml(Object(craft\elements\Entry), false)
#9 /app/vendor/craftcms/cms/src/web/View.php(1879): craft\models\FieldLayout->craft\models\{closure}()
#10 /app/vendor/craftcms/cms/src/models/FieldLayout.php(1012): craft\web\View->namespaceInputs(Object(Closure), NULL)
#11 /app/vendor/craftcms/cms/src/controllers/ElementsController.php(1013): craft\models\FieldLayout->createForm(Object(craft\elements\Entry), false, Array)
#12 /app/vendor/craftcms/cms/src/controllers/ElementsController.php(406): craft\controllers\ElementsController->_prepareEditor(Object(craft\elements\Entry), false, true, Object(craft\web\Response), 'main-form', Object(Closure), Object(Closure), Object(Closure))
#13 [internal function]: craft\controllers\ElementsController->craft\controllers\{closure}(Object(craft\web\Response), 'main-form')
#14 /app/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(125): call_user_func(Object(Closure), Object(craft\web\Response), 'main-form')
#15 /app/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(50): craft\web\CpScreenResponseFormatter->_formatTemplate(Object(craft\web\Response), Object(craft\web\CpScreenResponseBehavior))
#16 /app/vendor/yiisoft/yii2/web/Response.php(1109): craft\web\CpScreenResponseFormatter->format(Object(craft\web\Response))
#17 /app/vendor/craftcms/cms/src/web/Response.php(341): yii\web\Response->prepare()
#18 /app/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#19 /app/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#20 /app/web/index.php(12): yii\base\Application->run()
#21 {main}

Additional info

  • Craft version: Craft Pro 5.6.1
  • PHP version: 8.3.13
  • Database driver & version:
  • Plugins & versions: CKEditor | 4.5.0
@kbergha kbergha added the bug label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant