Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20867

Invalid Argument error when creating Image field without setting (optional) validator configuration

    Details

    • Sprint:
      Aconcagua Sprint 1

      Description

      Through REST v2 (and likely the PAPI aswell), creating a ContentType with an Image FieldType, and omitting the validator configurations on it (since they are optional, as seen here) will cause an error:

      Warning: Invalid argument supplied for foreach() 
      in .../ezp5/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/Image/Type.php
      line 228
      

      Looking at the code, I tracked the error through the following files:

      1. Core/Repository/ContentTypeService:581; in a situation where the configurations are not passed through the REST request, $fieldDefinitionCreateStruct->validatorConfiguration is NULL.

      2. Core/FieldType/Image/Type.php:224 attempts to iterate through this. Since the argument is NULL, an error is thrown.

      This issue may be present in other places. An example of a place where it WAS considered is Core/FieldType/TextLine/Type:45, where the argument is cast to an array in the iteration.

        Activity

        Hide
        Filipe Dobreira (Inactive) added a comment - - edited
        Show
        Filipe Dobreira (Inactive) added a comment - - edited Proposed fix: https://github.com/ezsystems/ezpublish-kernel/pull/361
        Show
        Petar Spanja (Inactive) added a comment - fixed in ezpublish-kernel/master: https://github.com/ezsystems/ezpublish-kernel/commit/902fe5200a74aa472259f0275574ef1b1ed55311
        Hide
        Marcos Loureiro (Inactive) added a comment -

        This is also happening on binary file field.

        Show
        Marcos Loureiro (Inactive) added a comment - This is also happening on binary file field.
        Hide
        Petar Spanja (Inactive) added a comment -

        New pull request: https://github.com/ezsystems/ezpublish-kernel/pull/418

        This implements FieldType::applyDefaultValidatorConfiguration(), so the fix should be complete.

        Show
        Petar Spanja (Inactive) added a comment - New pull request: https://github.com/ezsystems/ezpublish-kernel/pull/418 This implements FieldType::applyDefaultValidatorConfiguration(), so the fix should be complete.
        Show
        Petar Spanja (Inactive) added a comment - Fixed in ezpublish-kernel/master: https://github.com/ezsystems/ezpublish-kernel/commit/ad545eeae46c3c8af249d675a09e4c08899fb933
        Hide
        Marcos Loureiro (Inactive) added a comment -

        QA Approved

        Show
        Marcos Loureiro (Inactive) added a comment - QA Approved

          People

          • Assignee:
            Unassigned
            Reporter:
            Filipe Dobreira (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 day, 6 hours, 30 minutes
              1d 6h 30m

                Agile