Since [#1894902] functions like module_invoke, module_invoke_all, module_implements and drupal_alter are deprecated.

This clearly shows that we need injection for plugins and entities.

CommentFileSizeAuthor
#63 1895266-63.patch27.54 KBdamiankloip
#63 interdiff.txt781 bytesdamiankloip
#60 drupal-1895266-60.patch27.61 KBdawehner
#60 interdiff.txt1.53 KBdawehner
#59 drupal-1895266-59.patch23.38 KBdawehner
#59 interdiff.txt4.54 KBdawehner
#57 1895266-57.patch28.13 KBdamiankloip
#57 interdiff.txt1.37 KBdamiankloip
#55 1895266-55.patch27.39 KBdamiankloip
#55 interdiff.txt5.32 KBdamiankloip
#52 1895266-51.patch22.6 KBdamiankloip
#49 1895266-49.patch24.16 KBdamiankloip
#49 interdiff.txt1.09 KBdamiankloip
#47 1895266-46.patch23.81 KBdamiankloip
#45 1895266-45.patch23.34 KBdamiankloip
#45 interdiff.txt15.31 KBdamiankloip
#37 drupal-1895266-37.patch23.58 KBdawehner
#36 1895266-36.patch22.28 KBdamiankloip
#34 1895266-34.patch22.28 KBdamiankloip
#26 1895266-26.patch22.87 KBdamiankloip
#26 interdiff.txt540 bytesdamiankloip
#23 1895266-22.patch22.88 KBdamiankloip
#23 interdiff.txt977 bytesdamiankloip
#19 1895266-19.patch24.57 KBdamiankloip
#19 interdiff.txt7.4 KBdamiankloip
#17 1895266-17.patch22.47 KBdamiankloip
#16 1895266-16.patch21.96 KBdamiankloip
#16 interdiff.txt1.04 KBdamiankloip
#15 1895266-14.patch21.39 KBdamiankloip
#15 interdiff.txt1.19 KBdamiankloip
#12 1895266-12.patch20.9 KBdamiankloip
#12 interdiff.txt1.25 KBdamiankloip
#10 1895266-10.patch20.22 KBdamiankloip
#9 1895266-9.patch20.52 KBdamiankloip
#9 interdiff.txt1.58 KBdamiankloip
#7 drupal-1895266-7.patch20.2 KBdawehner
#5 drupal-1895266-5.patch20.69 KBdawehner
#5 interdiff.txt2.42 KBdawehner
#3 drupal-1895266-3.patch20.15 KBdawehner
#3 interdiff.txt5.48 KBdawehner
#1 drupal-1895266-1.patch20.07 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
20.07 KB

Status: Needs review » Needs work

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

dawehner’s picture

Status: Needs work » Needs review
FileSize
5.48 KB
20.15 KB

Oh right so invokeAll takes an array of arguments.

Status: Needs review » Needs work

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

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.42 KB
20.69 KB

There are still problems which are caused by non-running hooks.

Status: Needs review » Needs work

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

dawehner’s picture

Status: Needs work » Needs review
FileSize
20.2 KB

That's just a rerole.

Status: Needs review » Needs work

The last submitted patch, drupal-1895266-7.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.58 KB
20.52 KB

This should atleast help a bit. I'm thinking maybe we should get the module handler when the view instance is created? or in build or something, and store it?

damiankloip’s picture

FileSize
20.22 KB

Sorry, this patch. Interdiff is still good.

Status: Needs review » Needs work

The last submitted patch, 1895266-10.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.25 KB
20.9 KB

Oh, and that hook is not right.

damiankloip’s picture

Title: Convert views to use the ExtensionHandler » Convert views to use the ModuleHandler

Status: Needs review » Needs work

The last submitted patch, 1895266-12.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.19 KB
21.39 KB

Ok, now I just need to move the $module_handler var out of the if/else conditional.

damiankloip’s picture

FileSize
1.04 KB
21.96 KB

We could convert the there stuff to use this too..

damiankloip’s picture

FileSize
22.47 KB

Missed the post render theme hooks.

damiankloip’s picture

So maybe we shoudl also pass the module handler into the executable from the container as this is a service now.

damiankloip’s picture

FileSize
7.4 KB
24.57 KB

Here is a patch that does that too. So ViewExecutableFactory now passes the module handler to the ViewExecutable instance.

dawehner’s picture

Great changes!!

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -1292,23 +1285,15 @@ public function render($display_id = NULL) {
-        $function = $base->name . '_views_pre_render';
-        if (function_exists($function)) {
-          $function($this);
-        }
...
-      $function = $GLOBALS['theme'] . '_views_pre_render';
-      if (function_exists($function)) {
-        $function($this);
+        $module_handler->invoke($base, 'views_pre_render', array($this));
       }
...
+      $module_handler->invoke($GLOBALS['theme'], 'views_pre_render', array($this));

Right so implementsHook works with themes as well, nice!

+++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.phpundefined
@@ -71,9 +72,17 @@ class ViewsDataCache {
+  public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $config, ModuleHandlerInterface $module_handler) {

We should document the constructor now, maybe?

Status: Needs review » Needs work

The last submitted patch, 1895266-19.patch, failed testing.

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -421,11 +429,13 @@ class ViewExecutable {
+    $this->moduleHandler = $module_handler;

We can't do that at the moment :( The problem is that for example an exposed form has the form stored in the form cache, which requires then the object to be serializable, which is not the case for PDO, so not for moduleHandler.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
977 bytes
22.88 KB
damiankloip’s picture

I think that is what we want now?

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.phpundefined
@@ -79,6 +79,17 @@ class ViewsDataCache {
+   *

One empty line too much :) /** hides */

But yeah this is how we should do it.

damiankloip’s picture

FileSize
540 bytes
22.87 KB

Fine! There you go ;)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

That is ready to roll now.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.phpundefined
index 898503f..7956546 100644
--- a/core/modules/views/lib/Drupal/views/ViewExecutable.php

--- a/core/modules/views/lib/Drupal/views/ViewExecutable.php
+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -978,10 +978,8 @@ public function build($display_id = NULL) {

@@ -978,10 +978,8 @@ public function build($display_id = NULL) {
     }
 
     // Let modules modify the view just prior to building it.
-    foreach (module_implements('views_pre_build') as $module) {
-      $function = $module . '_views_pre_build';
-      $function($this);
-    }
+    $module_handler = drupal_container()->get('module_handler');
+    $module_handler->invokeAll('views_pre_build', array($this));
 
     // Attempt to load from cache.
     // @todo Load a build_info from cache.
@@ -1102,10 +1100,7 @@ public function build($display_id = NULL) {

Can't ViewExecutable get this from the constructor?

Also I'm hoping #1875086: Improve DX of drupal_container()->get() can go in soon, this will need a re-roll once that's in.

dawehner’s picture

@catch
Sadly we can't see #1895266-22: Convert views to use the ModuleHandler
It seems to be that we need to solve this general serialization problem in various parts once we inject everything in any part.

dawehner’s picture

Status: Needs work » Needs review

So back to needs review?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Or even back to RTBC?

tim.plunkett’s picture

Issue tags: -VDC

#26: 1895266-26.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work
Issue tags: +VDC

The last submitted patch, 1895266-26.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
22.28 KB

rerolled.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the rerole!

Back to RTBC

damiankloip’s picture

FileSize
22.28 KB

Needed another reroll after ViewsDataCache changes for DestructionInterface.

dawehner’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
23.58 KB

Replaced everything with Drupal::service().

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

Annnd, back to RTBC again.

dawehner’s picture

Issue tags: -VDC

#37: drupal-1895266-37.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, drupal-1895266-37.patch, failed testing.

dawehner’s picture

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

#37: drupal-1895266-37.patch queued for re-testing.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

#37: drupal-1895266-37.patch queued for re-testing.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
damiankloip’s picture

Status: Needs work » Needs review
FileSize
15.31 KB
23.34 KB

Rerolled to use Drupal::moduleHandler()

Status: Needs review » Needs work

The last submitted patch, 1895266-45.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
23.81 KB

Rerolled, the ViewsDatCache patch got in..

Status: Needs review » Needs work

The last submitted patch, 1895266-46.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.09 KB
24.16 KB

Oops sorry, I stuffed up the merge slightly in ViewsDataCache!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice! That's green if it's green.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.phpundefined
@@ -40,6 +41,13 @@ class ViewsDataCache implements DestructableInterface {
+  /**
+   * The current language code.
+   *
    * @var array
    */
   protected $requestedTables = array();

Seems the merge of ViewsDataCache is still slightly stuffed :)

+++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.phpundefined
@@ -67,14 +75,32 @@ class ViewsDataCache implements DestructableInterface {
+  protected $rebuildCache;

Unused property...

damiankloip’s picture

Status: Needs work » Needs review
FileSize
22.6 KB

The ViewsDataCache class was all messed up :) Let's try this.

alexpott’s picture

Status: Needs review » Needs work

I think that we also need to replace the following calls into module_* as well.

if (!is_dir($config_dir) || !module_exists($module)) {
  continue;
}

In \Drupal\views\Tests\ViewTestData...

module_load_include('inc', 'views_ui', 'admin');

In Drupal\views\Plugin\views\wizard twice... The module_handler service has a loadInclude() method which performs the same task. Hmmm... although this plugin is provided by views so views ui might not be enabled???

module_load_include('inc', 'views', 'views.theme');

In views.module twice...

module_load_include('inc', 'views_ui', 'admin');

in Drupal\views\Tests\ViewsDataTest should use $this->container->get('module_handler')...

$implementations = module_implements($hook);

In Drupal\views\Tests\ViewsHooksTest should use $this->container->get('module_handler')...

module_load_include('inc', 'views_ui', 'admin');

In Drupal\views\tests\UI\TagTest should use $this->container->get('module_handler')...

    module_load_include('inc', 'views_ui', 'admin');
    module_load_include('inc', 'views', 'includes/ajax');

In Drupal\views_ui\Form\Ajax\ViewsFormBase... this FormInterface probably should have the container injected and use it....

damiankloip’s picture

in Drupal\views\Tests\ViewsDataTest should use $this->container->get('module_handler')...

See #1914256: Add all views hooks to hook_hook_info()

Fixing the other things now.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
5.32 KB
27.39 KB

I have made the other change, I have only converted the usage in the ajax form base, as there is a todo to remove them anyway.

Status: Needs review » Needs work

The last submitted patch, 1895266-55.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.37 KB
28.13 KB

Oh dear, I think I see what's going on here, these are failing because of how moduleHandler works :( If the module isn't enabled, it can't include the file. So we need to enable views_ui for those 2 tests.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

That's good again!

dawehner’s picture

FileSize
4.54 KB
23.38 KB

As written in IRC, removed the load include part.

dawehner’s picture

FileSize
1.53 KB
27.61 KB

Now for real, relative to #57

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, drupal-1895266-60.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
781 bytes
27.54 KB

Really bored of this issue now :)

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

This is back to RTBC, just reverting a change that shouldn't be there.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 12b09da and pushed to 8.x. Thanks!

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