No announcement yet.

What is this WARNING: E_WARNING: Undefined array key "maxLength"

  • Filter
  • Time
  • Show
Clear All
new posts

  • What is this WARNING: E_WARNING: Undefined array key "maxLength"

    With version 8.2.2and 3 Why do i get this warning each time i save an enum field:

    WARNING: E_WARNING: Undefined array key "maxLength" {"code":2,"message":"Undefined array key "maxLength""

    Click image for larger version

Name:	enum error.png
Views:	217
Size:	8.6 KB
ID:	105577

  • #2
    Hi murugappan,

    Please reproduce this error using Debug mode:, and then send the error log.


    • #3

      The Debug log below:

      I did some debugging
      tests and what i found was that it only happens when we create a fresh instance of espocrm using version 8.2.2 or 8.2.3 (not sure about 8.2.0 and 8.2.1). It does not happen when i save enums in instances which were upgraded from versions < 8.2.0
      Attached Files
      Last edited by murugappan; 04-29-2024, 10:51 PM.


      • #4
        The “Undefined array key” warning tells you that your code refers to an array key without a value.
        And in your case, it means that when you created the field with Enum type, you didn't specify any Options for it.

        Click image for larger version  Name:	image.png Views:	0 Size:	20.6 KB ID:	105592
        Last edited by victor; 04-29-2024, 10:53 PM.


        • #5

          Unfortunately, this is not true in my case. All the enums have options defined (see below). I did the same in version 8.1.5 and there were no problems. In version 8.1.5 i could save an empty enum and it will still work.

          Click image for larger version  Name:	enum_def.png Views:	0 Size:	28.9 KB ID:	105595

          Last edited by murugappan; 04-30-2024, 03:51 AM.


          • #6

            espocrm v8.2 added custom prefix..

            what is your config.php ? a copy from one old instance ?
            what is your entityDefs.json ?
            have you validation rules for this field ?

            add : "maxLength": 100 to field enum in entityDefs..


            • #7
              item victor

              Thank you for responding.

              (1) I know about the custom prefix and i set that to 'true' in config.php because i do not want the prefix as i already have the c_ prefix.
              (2) entityDefs.json? Which one and where?
              (3) I do not have any validation rules for these fields.

              add : "maxLength": 100 to field enum in entityDefs
              . my question is the same as (2).

              Additional Notes:
              (1) In the case where i upgraded, the problem des not exist when i change existing enum fields, it only happens when i add a new enum field. I upgraded from 8.1.5. Version 8.1.5 does not have this problem.
              (2) I tried multiple fresh installation from 8.2.0 to 8.2.3 and all of them have the same problem.

              Latest Update (2024-05-01)

              I did some further debugging. I compared the Custom->metadata->entitDef-><entity> for version 8.1.5 and 8.2.3. I found that the enum definition for 8.2.3 has the "maxLength" parameter for enum fields (s ee screencap below). In 8.1.5 this parameter is not there. So i removed the parameter in 8.2.3 and the warning disappeared. I may found the cause but not the solution. I am sorry I do not have the technical knowledge of espocrm code.​

              Click image for larger version

Name:	maxlength parameter.png
Views:	172
Size:	9.8 KB
ID:	105631
              Last edited by murugappan; 05-01-2024, 10:44 AM.


              • item
                item commented
                Editing a comment
                Hi murugappan,
                now you have give a "full helping info" .. but it's out of my knowledge now
                maybe have you a different php version ?

                when i say entityDefs, it's the entityDefs where you have this field.
                I have to see "maxLength" to my instance.. somewhere, and not somewhere.. certainly before or after Yuri have make this params.

                I have some enum field without this params, with this params and not warning. (i use last php version always)

              • murugappan
                murugappan commented
                Editing a comment

                (1) If you a upgrading from version 8.1.5, the existing enums do not have the "maxLength" and they do not produce this warnings. But if you create a new enum, the "maxLength" parameter appears and the warning will be logged.

                (2) The warnings appear only when we create or customize the enum field not when when the user uses them in the form. Yet i am still concerned because, as this is a PHP warning, i am not sure if later it may cause some other fatal issues. I would want to get rid of the problem before going into production mode.

                (3) My PHP Version is 8.1.12. Once i complete my re-engineering i will migrate them to PHP 8.2.x.

                (4) as you stated "...certainly before or after Yuri have make this params" I am not sure if there was any indication in any of the releases where this enhancement is mentioned or explained. I will check again, i could have missed it.
                Last edited by murugappan; 05-03-2024, 04:48 AM.

            • #8
              item yuri

              Any advise or resolution on this, please?


              • #9

                This problem is not resolved in 8.2.4. Any advise, please?​


                • #10
                  Looks like there is solutions to this. Did anyone else get this problem?


                  • #11
                    You have one empty option in your enum and that is configured to be default. I guess the error would go, if you either delete the empty option or refer default to another option.


                    • #12
                      shalmaxb hi,

                      Thank you for responding. I did as you advised and i still get the warning. This is testnum i created which has no blank option and default is set correctly (see screencap below):

                      Click image for larger version

Name:	enum_de2f.png
Views:	87
Size:	29.3 KB
ID:	106289


                      • #13
                        do you have any formula, that is setting the enum to empty?


                        • murugappan
                          murugappan commented
                          Editing a comment
                          Hi shalmaxb sorry for the late reply. I do not have any formula or optional conditions set. Just plain simple enum.

                      • #14
                        Hi All,

                        This is an update on the current status of the problem. With version 8.3.5 issue problem no longer occurs.

                        yuri Thank you.

                        THIS TOPIC IS NOW CLOSED.