This could be quite a big patch and need a few re-rolls so the sooner we can get this in the better.

Meta Issue.
#1916134: Remove module_* deprecated functions

CommentFileSizeAuthor
#102 drupal_2045927_102.patch41.91 KBherom
#99 drupal_2045927_99.patch41.33 KBsutharsan
#98 drupal_2045927_98.patch41.3 KBianthomas_uk
#95 drupal_2045927_95.patch41.65 KBxano
#92 drupal_2045927_92.patch41.64 KBianthomas_uk
#83 drupal_2045927_83.patch41.64 KBsutharsan
#78 drupal_2045927_78.patch43.53 KBianthomas_uk
#70 drupal_2045927_70.patch44.84 KBherom
#67 drupal_2045927_66.patch44.79 KBherom
#59 drupal_2045927_59.patch44.81 KBsutharsan
#58 drupal_2045927_58.patch44.76 KBianthomas_uk
#58 drupal_2045927-interdiff-58.txt1.17 KBianthomas_uk
#57 drupal_2045927_57.patch44.77 KBherom
#54 drupal_2045927_54.patch45.15 KBherom
#51 drupal_2045927_51.patch45.33 KBxano
#49 interdiff.txt5.06 KBherom
#48 interdiff.txt5.97 KBxano
#48 drupal_2045927_48.patch45.57 KBxano
#44 drupal-replace-all-drupal_alter-2045927-44.patch46.43 KBherom
#41 drupal-replace-all-drupal_alter-2045927-41.patch46.47 KBherom
#39 drupal-replace-all-drupal_alter-2045927-39.patch48.41 KBherom
#39 interdiff-2045927-36-39.txt1.45 KBherom
#36 drupal-replace-all-drupal_alter-2045927-36.patch48.07 KBherom
#36 interdiff-2045927-19-36.txt11.05 KBherom
#32 interdiff-17-19.txt5.18 KBmartin107
#32 drupal-replace-all-drupal_alter-2045927-19.patch47.4 KBmartin107
#28 interdiff-17-18.txt4.2 KBmartin107
#28 drupal-replace-all-drupal_alter-2045927-18.patch47.4 KBmartin107
#25 interdiff-16-17.txt844 bytesmartin107
#25 drupal-replace-all-drupal_alter-2045927-17.patch44.98 KBmartin107
#20 interdff-15-16.txt2.61 KBmartin107
#20 drupal-replace-all-drupal_alter-2045927-16.patch44.42 KBmartin107
#17 interdiff-14-15.txt5.59 KBmartin107
#17 drupal-replace-all-drupal_alter-2045927-15.patch44.42 KBmartin107
#15 interdiff-13-14.txt16.1 KBmartin107
#15 drupal-replace-all-drupal_alter-2045927-14.patch45.16 KBmartin107
#14 interdiff-12-13.txt35.76 KBmartin107
#14 drupal-replace-all-drupal_alter-2045927-13.patch30.84 KBmartin107
#12 drupal-replace-all-drupal_alter-2045927-12.patch45.64 KBmichaellander
#5 drupal-replace-all-drupal_alter-2045927-5.patch50.67 KBmichaellander
#3 drupal-replace-all-drupal_alter-2045927-3.patch45.1 KBmichaellander
#2 drupal-replace-all-drupal_alter-2045927-2.patch49.52 KBmichaellander
#75 drupal_2045927_75.patch44.37 KBianthomas_uk
#72 drupal_2045927_72.patch44.36 KBxano

Comments

benjy’s picture

Issue tags: +Novice

Tagging

michaellander’s picture

Status: Active » Needs review
StatusFileSize
new49.52 KB

Wasn't sure about what to do with appearances in comments and drupal_alter('drupal_alter',...

Edit: crap, it did a permissions change, let me fix.

michaellander’s picture

Fixed permissions change in patch, sorry about that.

benjy’s picture

Status: Needs review » Needs work

Please don't use absolute references to the Drupal class.

michaellander’s picture

Status: Needs work » Needs review
StatusFileSize
new50.67 KB

Removed absolute references

Status: Needs review » Needs work

The last submitted patch, drupal-replace-all-drupal_alter-2045927-5.patch, failed testing.

michaellander’s picture

Status: Needs work » Needs review

Previous patch removed absolute references from the Drupal classes on a few existing usages as well, ie:

-    \Drupal::moduleHandler()->alter('user_format_name', $name, $this);
+    Drupal::moduleHandler()->alter('user_format_name', $name, $this);

Should I leave those or replace them?

michaellander’s picture

Status: Needs review » Needs work
benjy’s picture

michaellander, just leave any existing instances they can be fixed in a follow up.

benjy’s picture

michaellander, seems I mislead you a bit on the absolute paths vs relative. They have to be absolute in files with a namespace (which I didn't realise).

Here's the relevant link to the docs so you can see for yourself :) https://drupal.org/node/1353118

michaellander’s picture

Thanks for the reference, I'll get to it ASAP.

michaellander’s picture

Status: Needs work » Needs review
StatusFileSize
new45.64 KB

Absolute in files with namespace, relative in other files

enhdless’s picture

Issue summary: View changes
Status: Needs review » Needs work

Patch is in need of rerolling.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new30.84 KB
new35.76 KB

ReRoll + application of coding standard

its

\Drupal::moduleHandler()->alter

NOT

Drupal::moduleHandler()->alter

Otherwise a potential namespace conflict is introduced.

https://drupal.org/node/1353118

martin107’s picture

Ok so previous patch was a single minded reroll

This path results from a review ... global search reveals a few more function calls missing from previous patch.
For the first time It also addresses references to function calls in comments.

martin107’s picture

I am a bit uneasy about rtbc'ing this issue as I supplied the last patch... but It is no more than a search replace
exercise ... I will rtbc tomorrow.

martin

martin107’s picture

Patch 14 has whitespace issues and needed quick reroll.

martin107’s picture

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

Status: Reviewed & tested by the community » Needs work

Needs a reroll

martin107’s picture

Assigned: Unassigned » martin107
StatusFileSize
new44.42 KB
new2.61 KB

one line ReRoll

martin107’s picture

Status: Needs work » Needs review
martin107’s picture

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

Can you post a version of the patch with the drupal_alter function removed so we can be sure nothing else is still using it.

Also, it's usually recommended to wait for a second pair of eyes to RTBC an issue. https://drupal.org/patch/review

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Indeed, please don't RTBC your own patch. It's probably good to go after a grep confirms all old functions were replaced, however.

martin107’s picture

Ok so this patch removed definition of drupal_alter. Lets see what blows up

If this passes I will leave it for others to RTBC

My concern is that because the patch alters so many regularly touched files any delay will lead to a spiral of constant rerolls.

martin107’s picture

Cool its green

All lines reported by grep -R 'drupal_alter(' * can be accounted for

I should have mentioned this earlier..

Note From only the modules I commonly have installed this will have knock on consequences for
Devel and XHprof. Not sure how to signal this to contrib?

herom’s picture

Status: Needs review » Needs work
  1. +++ b/core/includes/bootstrap.inc
    @@ -2165,13 +2165,13 @@ function module_invoke($module, $hook) {
    + * @see \Drupal::moduleHandler->alter()
    
    @@ -2146,13 +2146,13 @@ function module_implements($hook) {
    + * @see \Drupal::moduleHandler->alter()
    
    +++ b/core/includes/theme.maintenance.inc
    @@ -75,9 +75,10 @@ function _drupal_maintenance_theme() {
    +  // list_themes() triggers a \Drupal::moduleHandler->alter() in maintenance
    

    the parentheses are missing for "moduleHandler", in many cases.

  2. +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
    @@ -403,7 +403,7 @@ public function buildContentsCssJSSetting(EditorEntity $editor) {
    +    \Drupal::moduleHandler()->alter('ckeditor_css', $css, $editor);
    
    +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php
    @@ -538,7 +538,7 @@ public function getBundleExtraFields($entity_type, $bundle) {
    +    \Drupal::moduleHandler()->alter('field_extra_fields', $extra);
    

    should use $this->moduleHandler.

  3. +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php
    @@ -85,7 +85,7 @@ public function getAttachments(array $format_ids) {
    +    \Drupal::moduleHandler()->alter('editor_js_settings', $settings);
    

    storing and using $this->moduleHandler should be easy for this too, since it is already passed a $module_handler in __construct, it just lets go.

  4. +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
    @@ -242,7 +242,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
    +      \Drupal::moduleHandler()->alter(array($view_hook, 'entity_view'), $build[$key], $entity, $display);
    
    @@ -202,7 +202,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
    +      \Drupal::moduleHandler()->alter('entity_view_mode', $entity_view_mode, $entity, $context);
    

    we can also use dependency-injection for moduleHandler here, and a few other classes; I just don't know if that's always preferred over \Drupal::moduleHandler().

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new47.4 KB
new4.2 KB

Thanks herom,

Here is a patch that corrects the issues raised in #27

Points 1,2 and 3

Points 3 and 4 raise very good points about explicit injection and it is certainly best practise

but I did not implement point 4 as this issue is about removing calls to a deprecated function. And correcting style is outside the scope of this issue.

herom’s picture

@martin107, that's not a proper interdiff. can you make one this way? you'll notice the difference in readability.

The last submitted patch, 28: drupal-replace-all-drupal_alter-2045927-18.patch, failed testing.

The last submitted patch, 28: drupal-replace-all-drupal_alter-2045927-18.patch, failed testing.

martin107’s picture

Ok so patch 18 has an flaw which is corrected by patch 19

So back to comment #28 and to restate

patch-19 addresses points 1, 2, 3 of comment #27

Thanks for the correction on the interdiffs. interdiff-17-19.txt is in the acceptable form.

martin107’s picture

Assigned: martin107 » Unassigned
herom’s picture

This needs a reroll. Otherwise, It's ready.

@martin107, just one minor note for later patches: the last number in your patch name should be the comment number it goes in. for example, your last patch would have been drupal-replace-all-drupal_alter-2045927-32.patch

dawehner’s picture

  1. +++ b/core/includes/bootstrap.inc
    @@ -2124,7 +2124,7 @@ function drupal_get_bootstrap_phase() {
    + * @see \Drupal\Core\Extension\ModuleHandler()::getModuleList()
    ...
    - * @see \Drupal\Core\Extension\ModuleHandler::getModuleList()
    
    @@ -2137,7 +2137,7 @@ function module_list() {
    + * @see \Drupal\Core\Extension\ModuleHandler()::getImplementations()
    ...
      *
    - * @see \Drupal\Core\Extension\ModuleHandler::getImplementations()
    
    @@ -2199,7 +2188,7 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
    - * @see \Drupal\Core\Extension\ModuleHandler::moduleExists()
    + * @see \Drupal\Core\Extension\ModuleHandler()::moduleExists()
    
    @@ -2211,7 +2200,7 @@ function module_exists($module) {
    - * @see \Drupal\Core\Extension\ModuleHandler::implementsHook()
    + * @see \Drupal\Core\Extension\ModuleHandler()::implementsHook()
    

    This is a wrong change as we certainly don't call the ModuleHandler as method

  2. +++ b/core/includes/theme.maintenance.inc
    @@ -75,9 +75,10 @@ function _drupal_maintenance_theme() {
    +  // list_themes() triggers a \Drupal::moduleHandler->alter() in maintenance
    

    We should probably point to the method or even just the interface itself?

  3. +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php
    --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
    +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
    
    index 3ace025..d0e28e7 100644
    --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
    
    +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
    --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
    +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
    
    index ec256c3..c1fadb4 100644
    --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
    

    Should not we try to implement this with proper injection instead of calling a global method.

herom’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new11.05 KB
new48.07 KB

addressed issues in #35.

Status: Needs review » Needs work

The last submitted patch, 36: drupal-replace-all-drupal_alter-2045927-36.patch, failed testing.

webchick’s picture

Hey there!

Given https://groups.drupal.org/node/394763, and given how much this changes and how easy it is to be broken by other patches (and thus also break other peoples' patches) I think what makes sense here is to pick a date sometime the week of Wed. Jan. 22 - Tues. Jan 28 (excluding 25 - 27 for Global Sprint Weekend) to get this sucker in. Is there a particular date in there that works for you?

herom’s picture

Status: Needs work » Needs review
StatusFileSize
new1.45 KB
new48.41 KB

@webchick I'm available the whole week. I'd say Jan. 23, but any other date would be fine by me too.

(updated patch: just some missing use statements)

sun’s picture

Issue tags: +@deprecated
herom’s picture

StatusFileSize
new46.47 KB

rerolled.
remaining tasks: rtbc.

Status: Needs review » Needs work

The last submitted patch, 41: drupal-replace-all-drupal_alter-2045927-41.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
herom’s picture

StatusFileSize
new46.43 KB

rerolled.
yep, this patch breaks fast.

Status: Needs review » Needs work

The last submitted patch, 44: drupal-replace-all-drupal_alter-2045927-44.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
webchick’s picture

Ok, I'm done committing stuff for the night, if you can get this passing and ping someone in #drupal-contribute to RTBC it, I can get it in tomorrow (in about ~8-10 hours :))

xano’s picture

StatusFileSize
new45.57 KB
new5.97 KB

I removed some redundant code and improved code comments.

herom’s picture

StatusFileSize
new5.06 KB

that last interdiff is a bit weird. this one's a better version for that.

alvar0hurtad0’s picture

Not sure, but After applying the patch there's lot of drupal_alter calls:

./core/modules/editor/lib/Drupal/editor/Entity/Editor.php: drupal_alter('editor_default_settings', $default_settings, $this->editor);
./core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php: drupal_alter('editor_js_settings', $settings);
./core/modules/toolbar/toolbar.module: drupal_alter('toolbar', $items);
./core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php: drupal_alter(array('query', 'query_' . $tag), $query);
./core/modules/node/node.module: drupal_alter('node_grants', $grants, $account, $op);
./core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php: drupal_alter('node_grants', $altered_grants, $web_user, $op);
./core/modules/contextual/contextual.module: drupal_alter('contextual_links_view', $element, $items);
./core/modules/field/field.deprecated.inc: drupal_alter('field_attach_view', $output, $context);
./core/modules/field/field.views.inc: * not to conflict with the drupal_alter('field_views_data') in
./core/modules/field/field.module: drupal_alter('field_attach_view', $result, $context);
./core/modules/field/lib/Drupal/field/FieldInfo.php: drupal_alter('field_extra_fields', $extra);
./core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php: drupal_alter('ckeditor_css', $css, $editor);
./core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php: drupal_alter('field_widget_settings_form', $settings_form, $form_state, $context);
./core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php: drupal_alter('field_widget_settings_summary', $summary, $context);
./core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php: drupal_alter('field_formatter_settings_form', $settings_form, $form_state, $context);
./core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php: drupal_alter('field_formatter_settings_summary', $summary, $context);
./core/modules/locale/locale.compare.inc: drupal_alter('locale_translation_projects', $projects);
./core/modules/xmlrpc/xmlrpc.server.inc: drupal_alter('xmlrpc', $callbacks);
./core/modules/update/update.compare.inc: drupal_alter('update_status', $projects);
./core/modules/system/system.module: drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
./core/modules/system/system.api.php: * Note that hooks invoked using drupal_alter() can have multiple variations
./core/modules/system/system.api.php: * (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter()
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: * Tests alteration of arguments passed to drupal_alter().
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: 'description' => 'Tests alteration of arguments passed to drupal_alter().',
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: drupal_alter('drupal_alter', $array_copy);
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: drupal_alter('drupal_alter', $entity_copy);
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: drupal_alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: $this->assertEqual($array_copy, $array_expected, 'First argument to drupal_alter() was altered.');
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: $this->assertEqual($entity_copy, $entity_expected, 'Second argument to drupal_alter() was altered.');
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: $this->assertEqual($array2_copy, $array2_expected, 'Third argument to drupal_alter() was altered.');
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: // Verify alteration order when passing an array of types to drupal_alter().
./core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php: drupal_alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
./core/modules/system/tests/modules/common_test/common_test.module: * This is for verifying that drupal_alter(array(TYPE1, TYPE2), ...) allows
./core/modules/system/tests/modules/common_test/common_test.module: // For drupal_alter(array('drupal_alter', 'drupal_alter_foo'), ...), make the
./core/modules/system/tests/modules/common_test/common_test.module: // when drupal_alter() is called with an array of types, the first type is
./core/modules/system/tests/themes/test_theme/test_theme.theme: * drupal_alter('theme_test_alter').
./core/modules/simpletest/simpletest.module: drupal_alter('simpletest', $groups);
./core/modules/file/file.module: drupal_alter('file_download_access', $grants, $context);
./core/includes/file.inc: drupal_alter('stream_wrappers', $wrappers);
./core/includes/file.inc: drupal_alter('file_url', $uri);
./core/includes/path.inc: drupal_alter('admin_paths', $paths);
./core/includes/menu.inc: drupal_alter('menu_get_item', $router_item, $path, $original_map);
./core/includes/menu.inc: drupal_alter('translated_menu_link', $item, $map);
./core/includes/menu.inc: drupal_alter('menu', $callbacks);
./core/includes/form.inc: drupal_alter('batch', $batch);
./core/includes/bootstrap.inc: * All arguments are passed by value. Use drupal_alter() if you need to pass
./core/includes/bootstrap.inc: * @see drupal_alter()
./core/includes/bootstrap.inc: * All arguments are passed by value. Use drupal_alter() if you need to pass
./core/includes/bootstrap.inc: * @see drupal_alter()
./core/includes/bootstrap.inc:function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
./core/includes/mail.inc: drupal_alter('mail', $message);
./core/includes/file.mimetypes.inc: drupal_alter('file_mimetype_mapping', $mapping);
./core/includes/common.inc: drupal_alter('html_head', $elements);
./core/includes/common.inc: * (optional) If set to TRUE, this function skips calling drupal_alter() on
./core/includes/common.inc: drupal_alter('css', $css);
./core/includes/common.inc: * (optional) If set to TRUE, this function skips calling drupal_alter() on
./core/includes/common.inc: drupal_alter('js', $javascript);
./core/includes/common.inc: drupal_alter('library_info', $module_libraries, $module);
./core/includes/common.inc: drupal_alter('queue_info', $queues);
./core/includes/common.inc: drupal_alter('page', $page);
./core/includes/common.inc: drupal_alter('element_info', $cache);
./core/includes/common.inc: drupal_alter('updater_info', $updaters);
./core/includes/common.inc: drupal_alter('filetransfer_info', $info);
./core/includes/theme.maintenance.inc: // list_themes() triggers a drupal_alter() in maintenance mode, but we can't
./core/includes/schema.inc: drupal_alter('schema', $schema);
./core/includes/entity.inc: drupal_alter('entity_form_mode_info', $form_modes);
./core/includes/entity.inc: drupal_alter('entity_view_mode_info', $view_modes);
./core/includes/entity.inc: drupal_alter('entity_display', $display, $display_context);
./core/includes/entity.inc: drupal_alter('entity_form_display', $form_display, $form_display_context);
./core/includes/theme.inc: drupal_alter('template_preprocess_default_variables', $variables);
./core/includes/ajax.inc: drupal_alter($type, $items[$type]);
./core/includes/ajax.inc: drupal_alter('ajax_render', $commands);
./core/lib/Drupal/Core/Entity/EntityViewBuilder.php: drupal_alter('entity_view_mode', $entity_view_mode, $entity, $context);
./core/lib/Drupal/Core/Entity/EntityViewBuilder.php: drupal_alter(array($view_hook, 'entity_view'), $build[$key], $entity, $display);
./core/lib/Drupal/Core/Transliteration/PHPTransliteration.php: drupal_alter('transliteration_overrides', $this->languageOverrides[$langcode], $langcode);
./core/lib/Drupal/Core/Database/Query/Select.php: drupal_alter($hooks, $query);
./core/lib/Drupal/Core/Field/WidgetBase.php: drupal_alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context);
./core/lib/Drupal/Core/Ajax/AjaxResponse.php: drupal_alter($type, $items[$type]);
./core/lib/Drupal/Core/Ajax/AjaxResponse.php: drupal_alter('ajax_render', $commands);

xano’s picture

StatusFileSize
new45.33 KB

Re-roll.

Not sure, but After applying the patch there's lot of drupal_alter calls:

Then I'm afraid something went wrong while you applied the patch. No occurrences show up when I apply it, and the tests would have failed if anything had been left, because the patch also removes the original function. Are you sure you are using an up-to-date code base, and that no errors are reported when you applied the patch?

dawehner’s picture

+++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
@@ -20,6 +24,30 @@ class DisplayOverview extends DisplayOverviewBase {
+  ¶

Ups :)

nko’s picture

Patch from #51 worked for me

herom’s picture

StatusFileSize
new45.15 KB

fixed #52 (trailing whitespace).

Status: Needs review » Needs work

The last submitted patch, 54: drupal_2045927_54.patch, failed testing.

The last submitted patch, 54: drupal_2045927_54.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
StatusFileSize
new44.77 KB

reroll.

ianthomas_uk’s picture

Issue tags: -Novice
StatusFileSize
new1.17 KB
new44.76 KB

Most of the patch looks good, and I'd RTBC it except it's using \Drupal instead of $this->moduleHandler in EntityViewBuilder.

Here's a patch to fix that.

sutharsan’s picture

StatusFileSize
new44.81 KB

Rerolled. Patch in #58 did no longer apply.

ianthomas_uk’s picture

Thanks for the reroll, but the patch that meant it needed a reroll also broke HEAD, so we might need to go back to #58. See #2172561: Config overrides may spill over to undesired places.

sutharsan’s picture

Status: Needs review » Needs work

Core is currently a fast moving target. More rerolls needed.

Reviewed #59:

  1. +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
    @@ -22,13 +26,38 @@ class DisplayOverview extends DisplayOverviewBase {
    +  /**
    +   * Constructs a new class instance.
    +   *
    +   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    +   *   The entity manager.
    +   * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager
    +   *   The field type manager.
    +   * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
    +   *   The widget or formatter plugin manager.
    +   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    +   *   The module handler class to use for invoking hooks.
    +   */
    +  public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) {
    +    parent::__construct($entity_manager, $field_type_manager, $plugin_manager);
    +    $this->moduleHandler = $module_handler;
    +  }
    

    Most __construct descriptions include the class name. e.g. Constructs a DisplayOverride object.

  2. +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
    @@ -22,13 +26,38 @@ class FormDisplayOverview extends DisplayOverviewBase {
    +  /**
    +   * Constructs a new class instance.
    +   *
    +   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    +   *   The entity manager.
    +   * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager
    +   *   The field type manager.
    +   * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
    +   *   The widget or formatter plugin manager.
    +   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    +   *   The module handler to use for invoking hooks.
    +   */
    +  public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) {
    +    parent::__construct($entity_manager, $field_type_manager, $plugin_manager);
    +    $this->moduleHandler = $module_handler;
    +  }
    

    See above.

ianthomas_uk’s picture

That's three rerolls required in 36 hours.

@webchick, I think we need to agree a time to get this committed, as you suggested in #38. I'm around for the next three evenings GMT+0 to re-roll this, would one of those work? If not, sutharsan and herom have also been pretty active and might be able to reroll it at another time.

xano’s picture

Most __construct descriptions include the class name. e.g. Constructs a DisplayOverride object.

They do, but that also forces any child class to override the method and docblock, because otherwise it will no longer be true. This works for inherited methods as well, and prevents us from having to change the line if we change the class's name in the future. See #2140961: Allow constructor methods to omit docblocks for a discussion.

webchick’s picture

Unfortunately, the next 3 days are bad for me because I'm traveling. :( However, I'm online for the next ~8 hours if someone gets to it before then.

xano’s picture

Status: Needs work » Needs review

Settings to needs review again as the concerns from #61 have been addressed.

sutharsan’s picture

I did review #58 and #59 and have no other concerns. As far as I'm concerned it is RTBC, but test needs to pass first and we need a reroll as it currently (commit 09d4037aa17) does not apply.

herom’s picture

StatusFileSize
new44.79 KB

another reroll.

The last submitted patch, 59: drupal_2045927_59.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 67: drupal_2045927_66.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
StatusFileSize
new44.84 KB

reroll.

ianthomas_uk’s picture

Status: Needs review » Reviewed & tested by the community

RTBC if green. Confirmed patch applies and only changes hunk context compared to previous patches.

xano’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new44.36 KB

Re-roll.

sun’s picture

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

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

drupal_2045927_72.patch no longer applies.

error: patch failed: core/includes/entity.inc:645
error: core/includes/entity.inc: patch does not apply

ianthomas_uk’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new44.37 KB

Re-roll, just fixes the hunk mentioned in #74.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/includes/bootstrap.inc
@@ -1952,17 +1952,6 @@ function module_invoke_all($hook) {
-/**
- * Passes alterable variables to specific hook_TYPE_alter() implementations.
- *
- * @deprecated as of Drupal 8.0. Use
- *   \Drupal::moduleHandler()->alter($hook).
- *
- * @see \Drupal\Core\Extension\ModuleHandler::alter()
- */
-function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
-  return \Drupal::moduleHandler()->alter($type, $data, $context1, $context2);
-}

Can we remove this and do this is a separate patch - that way we're much likely to break HEAD - and if we do we have a much smaller patch to roll back.

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new43.53 KB

This patch keeps the drupal_alter function, but I've updated the docblock to include removal information, as discussed in #2158871: [Policy, no patch] Clearly denote when @deprecated code is slated to be removed (see #62, referencing #59)

It's also a reroll to fix conflicts with #2090509: Optimize entity_get_render_display() for the case of "multiple entity view" in core/includes/entity.inc (hunks removed because the conflicting commit already uses the new method) and a context change in core/lib/Drupal/Core/Entity/EntityViewBuilder.php.

Status: Needs review » Needs work

The last submitted patch, 78: drupal_2045927_78.patch, failed testing.

herom’s picture

Status: Needs work » Needs review

78: drupal_2045927_78.patch queued for re-testing.

sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

I noticed the difference in the '@deprecated' text:
Old: @deprecated as of Drupal 8.0
New: @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
Although the discussion on this subject is not completely finished (#2158871: [Policy, no patch] Clearly denote when @deprecated code is slated to be removed), I don't think this change should block RTBC of this issue.

Patch still applies and no new drupal_alter() functions have been added in the meantime.

alexpott’s picture

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

drupal_2045927_78.patch no longer applies.

error: patch failed: core/modules/field/field.deprecated.inc:486
error: core/modules/field/field.deprecated.inc: patch does not apply
error: patch failed: core/modules/field/field.module:462
error: core/modules/field/field.module: patch does not apply

sutharsan’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new41.64 KB

Rerolled #78 patch.

#78 failed because drupal_alter('field_attach_view', ...) in field_view_field() and field_attach_view() got replaced by \Drupal::moduleHandler()->alter('entity_view_display', ...), in EntityViewDisplay::buildMultiple().

ianthomas_uk’s picture

Status: Needs review » Postponed

The reroll looks good, but the module_invoke patch has just been reverted #2045921: Replace all module_invoke() deprecated function calls..
Let's sort that issue before we bother rerolling again (or at least roll a patch that applies on top of any patch for that issue).

ianthomas_uk’s picture

Status: Postponed » Reviewed & tested by the community

#83 is good if applied with #2045921-59: Replace all module_invoke() deprecated function calls.

(patch will apply without #2045921, it will just miss an instance, so commit order doesn't matter too much)

xjm’s picture

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

Draft change records are now required before commit. The following change records need to be updated before we can consider this RTBC:
https://drupal.org/node/1829160
https://drupal.org/node/2056839
https://drupal.org/node/1882722
https://drupal.org/node/1833086

The main change record for this is https://drupal.org/node/1894902 and is already good to go, but it should be updated with a reference to this issue.

Also, to clarify, the patch does apply to HEAD as of 578bdec.

ianthomas_uk’s picture

RE #86

https://drupal.org/node/1829160/revisions/view/2755981/6917797 - done
https://drupal.org/node/2056839 - Mention is in D7 code, no change needed
https://drupal.org/node/1882722 - Todo, needs bigger changes
https://drupal.org/node/1833086/revisions/view/6917709/6917843 - done

I think https://drupal.org/node/1894902 also needs to be updated to reflect lack of additional context.

sutharsan’s picture

I've updated https://drupal.org/node/1882722 and https://drupal.org/node/1894902 with information on the context parameters.
@ianthomas_uk is that what you meant?

ianthomas_uk’s picture

Status: Needs work » Needs review

Yes for https://drupal.org/node/1894902, although the extra parameter was added in 7.22, not removed.

https://drupal.org/node/1882722 is a D7 change notice, so shouldn't include D8 sample code. I've changed this so there's just a small note about D8 at the end.

If these change records are good, please return to RTBC and remove the Needs change record tag.

sutharsan’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs change record

Change records are good. Back to RTBC.

alexpott’s picture

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

drupal_2045927_83.patch no longer applies.

error: patch failed: core/includes/ajax.inc:298
error: core/includes/ajax.inc: patch does not apply
error: patch failed: core/includes/common.inc:3563
error: core/includes/common.inc: patch does not apply

ianthomas_uk’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new41.64 KB

Rerolled

ianthomas_uk’s picture

Status: Needs review » Reviewed & tested by the community

Xano said this was ok to RTBC as it was just a context reroll. (drupal_json_encode becoming Json::encode in ajax.inc and a rewritten comment in common.inc)

alexpott’s picture

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

drupal_2045927_92.patch no longer applies.

error: patch failed: core/includes/entity.inc:130
error: core/includes/entity.inc: patch does not apply

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new41.65 KB

Re-roll.

diff a/core/includes/entity.inc b/core/includes/entity.inc	(rejected hunks)
@@ -130,7 +130,7 @@ function entity_get_form_modes($entity_type = NULL) {
         list($form_mode_entity_type, $form_mode_name) = explode('.', $form_mode->id(), 2);
         $form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
       }
-      drupal_alter('entity_form_mode_info', $form_modes);
+      \Drupal::moduleHandler()->alter('entity_form_mode_info', $form_modes);
       cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_info' => TRUE));
     }
   }
@@ -168,7 +168,7 @@ function entity_get_view_modes($entity_type = NULL) {
         list($view_mode_entity_type, $view_mode_name) = explode('.', $view_mode->id(), 2);
         $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
       }
-      drupal_alter('entity_view_mode_info', $view_modes);
+      \Drupal::moduleHandler()->alter('entity_view_mode_info', $view_modes);
       cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_info' => TRUE));
     }
   }
xano’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

RTBC, provided that the tests pass.

alexpott’s picture

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

drupal_2045927_95.patch no longer applies.

error: patch failed: core/includes/bootstrap.inc:1887
error: core/includes/bootstrap.inc: patch does not apply
error: patch failed: core/modules/editor/lib/Drupal/editor/Entity/Editor.php:73
error: core/modules/editor/lib/Drupal/editor/Entity/Editor.php: patch does not apply

ianthomas_uk’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
StatusFileSize
new41.3 KB

Reroll. Back to RTBC as it was just context changes.

sutharsan’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new41.33 KB
xano’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. RTBC if tests pass.

alexpott’s picture

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

drupal_2045927_99.patch no longer applies.

error: patch failed: core/includes/common.inc:2790
error: core/includes/common.inc: patch does not apply
error: patch failed: core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php:88
error: core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php: patch does not apply

herom’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
StatusFileSize
new41.91 KB

rerolled, and converted a single new case.

diff --git a/core/includes/common.inc b/core/includes/common.inc
@@ -2722,7 +2722,7 @@ function drupal_add_library($module, $name, $every_page = NULL) {
     if ($library = drupal_get_library($module, $name)) {
       // Allow modules and themes to dynamically attach request and context
       // specific data for this library; e.g., localization.
-      drupal_alter('library', $library, $module, $name);
+      \Drupal::moduleHandler()->alter('library', $library, $module, $name);
 
       // Add all components within the library.
       $elements['#attached'] = array(
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 78e5e9b and pushed to 8.x. Thanks!

Fixed during commit

diff --git a/core/includes/module.inc b/core/includes/module.inc
index 4c60604..97a69a0 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -116,8 +116,9 @@ function system_list_reset() {
 
   // Clear the library info cache.
   // Libraries may be provided by all extension types, and may be altered by any
-  // other extensions (types) due to the nature of drupal_alter() and the fact
-  // that profiles are recorded and handled as modules.
+  // other extensions (types) due to the nature of
+  // \Drupal\Core\Extension\ModuleHandler::alter() and the fact that profiles
+  // are recorded and handled as modules.
   Cache::invalidateTags(array('extension' => TRUE));
 
   // Remove last known theme data state.

Status: Fixed » Closed (fixed)

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

David_Rothstein’s picture

https://drupal.org/node/1829160/revisions/view/2755981/6917797 - done
https://drupal.org/node/2056839 - Mention is in D7 code, no change needed
https://drupal.org/node/1882722 - Todo, needs bigger changes
https://drupal.org/node/1833086/revisions/view/6917709/6917843 - done

Oops, the last one was actually Drupal 7 code also :)... But this is now removed from the change record anyway as a result of #1968348: (Change notice update) hook_field_formatter_prepare_view does not make use of hook_entity_view_mode_alter causing major errors