Handlers can be re ordered ok in the UI etc... when they are loaded, they keep their order. The problem is when they are saved. Currently views relies on the order of the handlers as their weighting; However, now we are using the config system, the display options are passed through ksort(). The offender is in Drupal\Core\Comnfig\Config.php:

  public function sortByKey(array &$data) {
    ksort($data);
    foreach ($data as &$value) {
      if (is_array($value)) {
        $this->sortByKey($value);
      }
    }
  }

So, either #1785560: Remove the sorting of configuration keys gets committed or we implement a 'weight' key on each handler and run each handler options array through drupal_sort_weight()?

Here are some tests that show this, currently failing behaviour.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, views-handler-weights-tests.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.12 KB

What about something like that?

Status: Needs review » Needs work

The last submitted patch, views-1798026-2.patch, failed testing.

dawehner’s picture

aspilicious’s picture

+++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.phpundefined
@@ -857,6 +857,15 @@ abstract class DisplayPluginBase extends PluginBase {
+      uasort($this->handlers[$type], function ($a, $b) {
+        $a_weight = isset($a->weight) ?: 0;
+        $b_weight = isset($b->weight) ?: 0;
+        if ($a_weight == $b_weight) {
+          return 0;
+        }
+        return ($a_weight < $b_weight) ? -1 : 1;

No more blocked, but I would move the search function to a static class function and call it here if possible. See uasort($categories, 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');

in this core patch: #1588422: Convert contact categories to configuration system

aspilicious’s picture

In fact that sort function is just the thing we need :)
http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/core/lib/D...

damiankloip’s picture

I personally think we should just wait for the linked issue in the summary to get in :) Then commit the tests at the top, as they should then pass.

damiankloip’s picture

Status: Needs work » Postponed
FileSize
2.94 KB

Re rolled and postponing on issue in summary.

tim.plunkett’s picture

Status: Postponed » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.