Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
19 Jul 2013 at 15:23 UTC
Updated:
4 Nov 2014 at 22:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
benjy commentedTagging
Comment #2
michaellander commentedWasn'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.
Comment #3
michaellander commentedFixed permissions change in patch, sorry about that.
Comment #4
benjy commentedPlease don't use absolute references to the Drupal class.
Comment #5
michaellander commentedRemoved absolute references
Comment #7
michaellander commentedPrevious patch removed absolute references from the Drupal classes on a few existing usages as well, ie:
Should I leave those or replace them?
Comment #8
michaellander commentedComment #9
benjy commentedmichaellander, just leave any existing instances they can be fixed in a follow up.
Comment #10
benjy commentedmichaellander, 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
Comment #11
michaellander commentedThanks for the reference, I'll get to it ASAP.
Comment #12
michaellander commentedAbsolute in files with namespace, relative in other files
Comment #13
enhdless commentedPatch is in need of rerolling.
Comment #14
martin107 commentedReRoll + application of coding standard
its
\Drupal::moduleHandler()->alter
NOT
Drupal::moduleHandler()->alter
Otherwise a potential namespace conflict is introduced.
https://drupal.org/node/1353118
Comment #15
martin107 commentedOk 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.
Comment #16
martin107 commentedI 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
Comment #17
martin107 commentedPatch 14 has whitespace issues and needed quick reroll.
Comment #18
martin107 commentedComment #19
benjy commentedNeeds a reroll
Comment #20
martin107 commentedone line ReRoll
Comment #21
martin107 commentedComment #22
martin107 commentedComment #23
benjy commentedCan 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
Comment #24
webchickIndeed, please don't RTBC your own patch. It's probably good to go after a grep confirms all old functions were replaced, however.
Comment #25
martin107 commentedOk 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.
Comment #26
martin107 commentedCool 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?
Comment #27
herom commentedthe parentheses are missing for "moduleHandler", in many cases.
should use $this->moduleHandler.
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.
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().
Comment #28
martin107 commentedThanks 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.
Comment #29
herom commented@martin107, that's not a proper interdiff. can you make one this way? you'll notice the difference in readability.
Comment #32
martin107 commentedOk 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.
Comment #33
martin107 commentedComment #34
herom commentedThis 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.patchComment #35
dawehnerThis is a wrong change as we certainly don't call the ModuleHandler as method
We should probably point to the method or even just the interface itself?
Should not we try to implement this with proper injection instead of calling a global method.
Comment #36
herom commentedaddressed issues in #35.
Comment #38
webchickHey 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?
Comment #39
herom commented@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)
Comment #40
sunComment #41
herom commentedrerolled.
remaining tasks: rtbc.
Comment #43
herom commented41: drupal-replace-all-drupal_alter-2045927-41.patch queued for re-testing.
Comment #44
herom commentedrerolled.
yep, this patch breaks fast.
Comment #46
herom commented44: drupal-replace-all-drupal_alter-2045927-44.patch queued for re-testing.
Comment #47
webchickOk, 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 :))
Comment #48
xanoI removed some redundant code and improved code comments.
Comment #49
herom commentedthat last interdiff is a bit weird. this one's a better version for that.
Comment #50
alvar0hurtad0Not 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);
Comment #51
xanoRe-roll.
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?
Comment #52
dawehnerUps :)
Comment #53
nko commentedPatch from #51 worked for me
Comment #54
herom commentedfixed #52 (trailing whitespace).
Comment #57
herom commentedreroll.
Comment #58
ianthomas_ukMost 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.
Comment #59
sutharsan commentedRerolled. Patch in #58 did no longer apply.
Comment #60
ianthomas_ukThanks 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.
Comment #61
sutharsan commentedCore is currently a fast moving target. More rerolls needed.
Reviewed #59:
Most __construct descriptions include the class name. e.g. Constructs a DisplayOverride object.
See above.
Comment #62
ianthomas_ukThat'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.
Comment #63
xanoThey 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.
Comment #64
webchickUnfortunately, 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.
Comment #65
xanoSettings to needs review again as the concerns from #61 have been addressed.
Comment #66
sutharsan commentedI 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.
Comment #67
herom commentedanother reroll.
Comment #70
herom commentedreroll.
Comment #71
ianthomas_ukRTBC if green. Confirmed patch applies and only changes hunk context compared to previous patches.
Comment #72
xanoRe-roll.
Comment #73
sunComment #74
alexpottdrupal_2045927_72.patch no longer applies.
Comment #75
ianthomas_ukRe-roll, just fixes the hunk mentioned in #74.
Comment #76
dawehnerback to RTBC.
Comment #77
alexpottCan 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.
Comment #78
ianthomas_ukThis 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.
Comment #80
herom commented78: drupal_2045927_78.patch queued for re-testing.
Comment #81
sutharsan commentedI noticed the difference in the '@deprecated' text:
Old:
@deprecated as of Drupal 8.0New:
@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.Comment #82
alexpottdrupal_2045927_78.patch no longer applies.
Comment #83
sutharsan commentedRerolled #78 patch.
#78 failed because
drupal_alter('field_attach_view', ...)infield_view_field()andfield_attach_view()got replaced by\Drupal::moduleHandler()->alter('entity_view_display', ...), inEntityViewDisplay::buildMultiple().Comment #84
ianthomas_ukThe 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).
Comment #85
ianthomas_uk#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)
Comment #86
xjmDraft 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.
Comment #87
ianthomas_ukRE #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.
Comment #88
sutharsan commentedI'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?
Comment #89
ianthomas_ukYes 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.
Comment #90
sutharsan commentedChange records are good. Back to RTBC.
Comment #91
alexpottdrupal_2045927_83.patch no longer applies.
Comment #92
ianthomas_ukRerolled
Comment #93
ianthomas_ukXano 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)
Comment #94
alexpottdrupal_2045927_92.patch no longer applies.
Comment #95
xanoRe-roll.
Comment #96
xanoRTBC, provided that the tests pass.
Comment #97
alexpottdrupal_2045927_95.patch no longer applies.
Comment #98
ianthomas_ukReroll. Back to RTBC as it was just context changes.
Comment #99
sutharsan commentedPatch #98 rerolled. Did not apply due to #2198343: Convert all usages of cache() and cache_invalidate_tags() procedural functions.
Comment #100
xanoLooks good. RTBC if tests pass.
Comment #101
alexpottdrupal_2045927_99.patch no longer applies.
Comment #102
herom commentedrerolled, and converted a single new case.
Comment #103
alexpottCommitted 78e5e9b and pushed to 8.x. Thanks!
Fixed during commit
Comment #105
David_Rothstein commentedOops, 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