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

    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

            Unassigned Unassigned
            9dcdb0dd-5caa-459b-93b0-1ce97332c3fa@accounts.ibexa.co Hannes Giesenow
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: