Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-3210

Form builder field ordering unpredictable on Postgres due to missing Order by

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: InputQ
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: 2.5.6
    • Fix Version/s: Customer request
    • Component/s: Form Builder
    • Labels:
      None
    • Environment:

      ezpublish-kernel: 7.5.6
      ezplatform-form-builder:1.2.5

      Postgres 11 Database

      Description

      From time to time, the form elements of a form are reordered in a uncontrolled way, when editing a form.

      Steps to reproduce:

      1. Create a form with 10 fields
      2. Edit the form
      3. see if error occurs
      4. if not, discard the draft and repeat at step 2.

      Solution:

      There is no explicit order given in the database query, so it's up to the database if it is going to sort it by id or not. In most cases it does, but in few cases it doesn't.

      The following patch would solve the problem:

      --- src/lib/FieldType/Storage/DoctrineGateway.php
      +++ src/lib/FieldType/Storage/DoctrineGateway.fixed.php
      @@ -345,7 +345,8 @@
               $selectQuery
                   ->from($this->connection->quoteIdentifier(self::TABLE_FIELDS))
                   ->where('form_id = :form_id')
      -            ->setParameter(':form_id', $formId, ParameterType::INTEGER);
      +            ->setParameter(':form_id', $formId, ParameterType::INTEGER)
      +            ->orderBy('id');
       
               $statement = $selectQuery->execute();

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            hannes.giesenow@elbformat.de Hannes Giesenow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: