Comments

legolasbo’s picture

Status: Active » Needs review
StatusFileSize
new4.55 KB

Attached patch removes all usage of and reference to form_get_cache()

Status: Needs review » Needs work

The last submitted patch, 1: remove_form_get_cache_usage-2355179-1.patch, failed testing.

Status: Needs work » Needs review
claudiu.cristea’s picture

Status: Needs review » Needs work

Greping I found also these:

$ grep -nr form_get_cache core
...
core/lib/Drupal/Core/Form/FormCache.php:186:    // to prevent legacy code operating directly with form_get_cache and
core/modules/system/src/Controller/FormAjaxController.php:131:    // replaced from within form_get_cache. If this is the case, it is also
core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php:44:   * form_get_cache and stored using form_set_cache after manipulation. This

But it seems that in core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php we should keep the references because it tells about Drupal 6.

legolasbo’s picture

Status: Needs work » Needs review
StatusFileSize
new6.22 KB

Removed the mentioned reference except for the reference in core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php because i agree we should keep that one.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Thank you. Looks good.

alexpott’s picture

Title: Remove usage of form_get_cache() » Remove usage of form_get_cache() and form_set_cache()
Status: Reviewed & tested by the community » Needs work

Can we combine #2355185: Remove usage of form_set_cache(). form_get_cache and form_set_cache should be removed together. Having one without the other - both patches are rtbc but they of course conflict. Let's add the form_set_cache() to this patch since this patch has the smaller nid.

legolasbo’s picture

Merged both patches

legolasbo’s picture

Status: Needs work » Needs review
alexpott’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Form/FormCache.php
@@ -183,8 +183,9 @@ public function setCache($form_build_id, $form, FormStateInterface $form_state)
+    // to prevent legacy code operating directly with \Drupal::formBuilder()->getCache()

Need to re-flow this comment to be less than 80 characters

pushpinderchauhan’s picture

Status: Needs work » Needs review
StatusFileSize
new7.58 KB

Need to re-flow this comment to be less than 80 characters

Done in this patch.

dinarcon’s picture

Status: Needs review » Reviewed & tested by the community

This seems to be ready. Only the following instances remains which @claudiu.cristea suggests to keep in #4

For form_get_cache():

core/modules/system/src/Tests/Form/FormCacheTest.php:64:    $cached_form = form_get_cache($this->form_build_id, $cached_form_state);
core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php:44:   * form_get_cache and stored using form_set_cache after manipulation. This
core/includes/form.inc:28:function form_get_cache($form_build_id, FormStateInterface $form_state) {

For form_set_cache():

core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php:44:   * form_get_cache and stored using form_set_cache after manipulation. This
core/includes/form.inc:40:function form_set_cache($form_build_id, $form, FormStateInterface $form_state) {
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed f803d64 on 8.0.x
    Issue #2355179 by legolasbo, er.pushpinderrana: Remove usage of...
andypost’s picture

Status: Fixed » Needs work

Needs follow-up

+++ b/core/modules/system/src/Controller/FormAjaxController.php
@@ -116,7 +116,7 @@ protected function getForm(Request $request) {
+    $form = \Drupal::formBuilder()->getCache($form_build_id, $form_state);

suppose service should be properly injected to controller

andypost’s picture

d.o lags

andypost’s picture

-

legolasbo’s picture

Status: Needs work » Fixed

The formbuilder only gets used once in that class, which does not justify injecting it as far as i know. I also think injecting it would be outside of the scope of this issue, because this issue and the meta issue it's part of focus on removing direct calls to deprecated functions. I think you should open a follow-up issue if you think the formbuilder should be injected.

webchick’s picture

Agreed. Let's do one thing at a time. :)

skipyT’s picture

we still have one more form_get_cache in FormCachetest::testCacheToken.

I updated the patch in #2355187 to take out that one also.

claudiu.cristea’s picture

@skipyT, see #4

skipyT’s picture

@claudiu.cristea: see https://www.drupal.org/node/2355187#comment-9249859 One test was failing because of that occurrence. And it is not the FormTestController, it is the FormCacheTest. Did I misunderstood something?

Status: Fixed » Closed (fixed)

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