Problem/Motivation

While performance testing on #1811816: Benchmark node_page_default vs. node view one issue was that PluginBase::setOptionDefaults was rather slow.

Proposed resolution

  • Remove the unneeded translation (discuss whether it makes sense to translate default values once we have metadata config translation in)
  • Simplify the code by requiring a default option (which is actually the case since d6.3)

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new7.36 KB

Status: Needs review » Needs work

The last submitted patch, drupal-1849280-1.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new8.02 KB
new679 bytes

Yeah this shows some bugs in defineOptions implementations.

Status: Needs review » Needs work

The last submitted patch, drupal-1849280-3.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new683 bytes
new8.02 KB

This time with a proper default value for the boolean handler.

berdir’s picture

Issue tags: -Performance, -VDC

#5: drupal-1849280-5.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-1849280-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#5: drupal-1849280-5.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-1849280-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#5: drupal-1849280-5.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-1849280-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#5: drupal-1849280-5.patch queued for re-testing.

dawehner’s picture

#5: drupal-1849280-5.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Performance, +VDC

The last submitted patch, drupal-1849280-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB

This contained some other patch internally.

Status: Needs review » Needs work
Issue tags: -Performance, -VDC

The last submitted patch, drupal-1849280-15.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#15: drupal-1849280-15.patch queued for re-testing.

dawehner’s picture

#15: drupal-1849280-15.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Performance, +VDC

The last submitted patch, drupal-1849280-15.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new971 bytes
new3.36 KB

Let's fix it.

dawehner’s picture

Issue tags: -Performance, -VDC

#20: drupal-1849280-20.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Performance, +VDC

The last submitted patch, drupal-1849280-20.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new3.44 KB

Just another rerole

Status: Needs review » Needs work
Issue tags: -Performance, -VDC

The last submitted patch, drupal-1849280-23.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +Performance, +VDC

#23: drupal-1849280-23.patch queued for re-testing.

tim.plunkett’s picture

Status: Needs review » Needs work

The changes look great! Two small nitpicks

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.phpundefined
@@ -99,17 +99,27 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
+   * Fill up the options of the plugin with defaults.

Fills

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.phpundefined
@@ -99,17 +99,27 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
+   *   An array which stores the actual option values of the plugin.
+   *
+   * @param array $options

No blank line needed

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.phpundefined
@@ -99,17 +99,27 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
+   *     - default: The default value of one option
+   *     - contains: (optional) An array which describes the available options
+   *       under the key.

These are indented 2 spaces too much, and the (optional) goes before the key name I think

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Boolean.phpundefined
@@ -38,7 +38,7 @@ protected function defineOptions() {
-    $options['not'] = array('definition bool' => 'reverse');
+    $options['not'] = array('default' => FALSE, 'bool' => TRUE);

Hahaha, what was that? :)

dawehner’s picture

Status: Needs work » Needs review

#23: drupal-1849280-23.patch queued for re-testing.

dawehner’s picture

StatusFileSize
new3.43 KB

Yeah indeed this patch showed some odd bugs in the code :)
Thanks for the review!

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

The removed $level param hasn't been used since Views 6.x-2.x, so in theory this clean-up could get backported.

Nice work @dawehner!

dawehner’s picture

Issue tags: -Needs backport to D7

We probably could only fix the $level parameter, but not the rest, as people might have broken option_defintions(),
so doesn't seems worth to do.

damiankloip’s picture

Issue tags: +Needs backport to D7
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.phpundefined
@@ -99,17 +99,26 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
       if (isset($definition['contains']) && is_array($definition['contains'])) {

If we are trimming the fat out of this method, should/could we also assume that if 'contains' is set, it will be an array.

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.phpundefined
@@ -99,17 +99,26 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
+   *   - default: The default value of one option
+   *   - (optional) contains: An array which describes the available options
+   *       under the key.

Small thing: Should we add the translatable key to the docs too?

I have also just opened #1922966: Remove 'bool' and 'translatable' key from option definitions as a related follow up.

damiankloip’s picture

Issue tags: -Needs backport to D7

Oops, must have x-posted

dawehner’s picture

StatusFileSize
new3.72 KB
new1.21 KB

Good points.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yay performance!

Committed and pushed to 8.x. Thanks!

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