The text field types are not in the correct order.

The code responsible for this is this in CategorizingPluginManagerTrait:

  public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') {
    // Sort the plugins first by category, then by label.
    /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */
    $definitions = isset($definitions) ? $definitions : $this->getDefinitions();
    uasort($definitions, function ($a, $b) use ($label_key) {
      if ($a['category'] != $b['category']) {
        return strnatcasecmp($a['category'], $b['category']);
      }
      return strnatcasecmp($a[$label_key], $b[$label_key]);
    });
    return $definitions;
  }

I've not yet managed to figure out why the sorting is incorrect.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

rosinegrean’s picture

Assigned: Unassigned » rosinegrean
Issue tags: +DCTransylvania
joachim’s picture

Very odd, this is working for me now.

Anyone else able to reproduce this?

rosinegrean’s picture

Assigned: rosinegrean » Unassigned

This is still the case for me, but was not able to work on it.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

yoroy’s picture

Running into this in another part of this list. I missed the "Date range" field because it was not right below "Date".

nesta_’s picture

Issue tags: +DevDaysSeville
aj2r’s picture

Assigned: Unassigned » aj2r
aj2r’s picture

Assigned: aj2r » Unassigned
Status: Active » Closed (cannot reproduce)
FileSize
67.61 KB

Hi, I cannot reproduce. It's OK for me in 8.4.x.

Issue is OK in 8.4.x

yoroy’s picture

Status: Closed (cannot reproduce) » Active

Did you check the top "General" section?

There's a specific case I'd like to see work better:
- Enable daterange experimental module
- Add a daterange field to a content type: where is daterange listed within the "General" section?

aj2r’s picture

Assigned: Unassigned » aj2r
aj2r’s picture

Assigned: aj2r » Unassigned
Status: Active » Closed (cannot reproduce)
FileSize
58.78 KB

@yoroy, yep, It's OK with Date range enabled:

2701867-13 OK

_Archy_’s picture

Issue tags: -DCTransylvania
mpdonadio’s picture

If this is CNR, what issue fixed it?

mpdonadio’s picture

Status: Closed (cannot reproduce) » Active
Issue tags: +Needs tests, +PHP 7.0 (duplicate)
FileSize
73.13 KB

Fresh install of 8.4.x w/ datetime_range installed from drush and UI:

However, this only happens when I am on PHP 7.0. With PHP 5.6, the sort order is correct.

mpdonadio’s picture

A little crude, but passes locally with PHP 5.6 and fails in PHP 7.0.

mpdonadio’s picture

o.O

Test is in https://dispatcher.drupalci.org/job/drupal_patches/21376/consoleFull showing a pass

But locally (PHP from my MAMP).

$ ../vendor/bin/phpunit --debug --verbose ../core/tests/Drupal/FunctionalTests/Field/FieldTypeSortTest.php
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

Runtime: PHP 7.0.12
Configuration: /Users/matt/Documents/PhpStorm/drupal-8.4.x/core/phpunit.xml

Starting test 'Drupal\FunctionalTests\Field\FieldTypeSortTest::testSortOrder'.
F

Time: 12.84 seconds, Memory: 6.00MB

There was 1 failure:

1) Drupal\FunctionalTests\Field\FieldTypeSortTest::testSortOrder
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 0 => 'Boolean'
- 1 => 'Comments'
+ 0 => 'Comments'
+ 1 => 'Boolean'
2 => 'Date'
- 3 => 'Date range'
+ 3 => 'Timestamp'
4 => 'Email'
- 5 => 'Link'
- 6 => 'Timestamp'
+ 5 => 'Date range'
+ 6 => 'Link'
)

/Users/matt/Documents/PhpStorm/drupal-8.4.x/core/tests/Drupal/Tests/BrowserTestBase.php:1366
/Users/matt/Documents/PhpStorm/drupal-8.4.x/core/tests/Drupal/FunctionalTests/Field/FieldTypeSortTest.php:52

FAILURES!
Tests: 1, Assertions: 7, Failures: 1.

mpdonadio’s picture

This is a wild theory, but I am wondering if CategorizingPluginManagerTrait::getSortedDefinitions() isn't running in some instances, and we are accidentally getting alphabetical results. I have seen similar things happen because of a filesystem quirk.

I forget the precise details, but the problem happens when files are written out in a different order on different system. When the system scans the directory, it picks them up in inode order. So, if a git clone is writing everything out alphabetically, then it will be read back that way. Locally, I have had this 8.4.x clone for ages, so file order b/c pulls may be different.

I'll test this out later with a fresh clone, just like testbot would.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Needs review » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative
FileSize
33.66 KB
38.92 KB

I tested this on 9.3.x and was not able to reproduce this error, see screenshots.

Therefore, closing as cannot reproduce. If you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").