Problem/Motivation
drupal_form_submit() is marked deprecated for 8.0.
Allowed in beta?
per https://www.drupal.org/contribute/core/beta-changes
This function is already marked for deprecation before and after this patch:
/**
* Retrieves, populates, and processes a form.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::formBuilder()->submitForm().
*
* @see \Drupal\Core\Form\FormBuilderInterface::submitForm().
*/
function drupal_form_submit($form_arg, FormStateInterface $form_state) {
The only usages left are the function definition itself, and a reference in
core/scripts/generate-d7-content.sh
which is ok. That d7.sh script should not be touched. It is to be executed on a d7 site, so should be using the d7 api.
core/includes/form.inc
28:function drupal_form_submit($form_arg, FormStateInterface $form_state) {
core/scripts/generate-d7-content.sh
269: drupal_form_submit('poll_view_voting', $form_state, $node);
Proposed resolution
Remove usage of drupal_form_submit(), including updating comments referencing drupal_form_submit() or drupal_prepare_form().
Remaining tasks
Make a child issue to actually remove the wrapper function from core.
User interface changes
No.
API changes
No.
Comments
Comment #1
shadik commentedComment #2
shadik commentedComment #4
shadik commentedComment #5
shadik commentedComment #7
shadik commentedComment #9
Miroling commentedComment #10
Miroling commentedComment #12
Miroling commentedComment #14
Miroling commentedComment #16
Miroling commentedComment #17
podarok#16 looks good. RTBC
Comment #18
gumanist commentedplease, update comments and usage in other files as well.
drupal/core/includes/batch.inc: // drupal_form_submit()), initialize a timer to determine whether we need to
drupal/core/includes/install.core.inc: * array that is passed on to the form submission via drupal_form_submit()).
drupal/core/includes/install.core.inc: // submission via drupal_form_submit().
drupal/core/lib/Drupal/Core/Form/FormBuilderInterface.php: * drupal_form_submit('mymodule_form', $form_state);
drupal/core/lib/Drupal/Core/Form/FormBuilderInterface.php: * drupal_form_submit('user_register_form', $form_state);
drupal/core/lib/Drupal/Core/Render/Element/Checkboxes.php: // should be unchecked; see drupal_form_submit(). We therefore remove all
drupal/core/modules/simpletest/src/InstallerTestBase.php: // suitable for a programmed drupal_form_submit().
drupal/core/modules/system/src/Tests/Batch/ProcessingTest.php: * Tests that drupal_form_submit() can run within a batch operation.
drupal/core/modules/system/src/Tests/Batch/ProcessingTest.php: $this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), 'drupal_formdrupal/core/modules/system/tests/modules/batch_test/batch_test.module: * Batch operation: Submits form_test_mock_form() using drupal_form_submit().
drupal/core/modules/system/tests/modules/batch_test/batch_test.module:function _batch_test_nested_drupal_form_submit_callback($value) {
drupal/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php: array('_batch_test_nested_drupal_form_submit_callback', array($value)),
drupal/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php: * drupal_form_submit().
drupal/core/scripts/generate-d7-content.sh: drupal_form_submit('poll_view_voting', $form_state, $node);
Comment #19
podarokComment #20
podarokComment #21
Miroling commentedComment #22
rpayanmComment #23
yesct commentedEvaluating per https://www.drupal.org/contribute/core/beta-changes
--
while looking at the patch, I saw a few things to change.
Patch coming.
Comment #24
yesct commentedthe overflow should be merged with the partial line/comment.
one line summaries should stay one line (80 chars or less).
"All summaries (first lines of docblocks) must be under 80 characters, start with a capital letter, and end with a period (.). They must provide a brief description of what a function does, what a class does, what a file contains, etc."
https://www.drupal.org/node/1354#drupal
Comment #25
yesct commentedNote, in this last one, form_test_mock_form() is an error, there is no such function anymore. It was removed in #2132477: Convert batch_test forms to controllers
I just reworded it this comment.
Comment #26
yesct commentedoops. now the grammar is off. Fix coming.
I left this and did not change it to Third person verb since the other summaries in this test module use this form.
Comment #27
yesct commentedComment #28
star-szrI reviewed the patch with
git diff --color-words(which I just found out works awesome when re-wrapping!) and it looks good from there.I verified the grep from the issue summary and there are no remaining usages/docs updates needed.
Some of the docs are slightly reworded to fit in 80 characters but they make more sense and fix references to things that are gone now.
RTBC!
Comment #29
alexpottThe existing change record should be updated to link to this issue.
Comment #30
rpayanmUpdate the CR.
Comment #31
alexpottI think this should be a link to \Drupal\Core\Form\FormBuilderInterface::submitForm() since I think the point here is to point the reader to the documentation there. In fact the correct thing might be to remove this and add an @see to the end of the doc block.
Comment #32
gaurav.pahuja commentedPlease review.
Comment #33
filijonka commentedthe @see shouldn't be added in the comment but to the docblock for the function per @alexpott comment
Comment #34
rpayanmComment #35
David Hernández commentedThe "@see" has been removed correctly from the code and now is part of the docblock from before the function.
Comment #36
yesct commentedI dont know if @alexpott really meant the end of the doc block /** ... */ on the method, or just at the end of the group of the in line comments.
... because I dont think our api parser, can parse @inheritdoc *AND* also additional documentation.
See #1994890-10: Allow {@inheritdoc} and additional documentation
Comment #37
filijonka commentedhi
wasn't aware of that we had an inherit doc so that's my fault but I also thought it was solved so we could use both inherit and a new tag, simply since I see it here and there. But apparently not.
anyway, the @see was on the end of the group of inline comments, and I'm not really sure what the point of using a @see on a inline comment is.
Comment #38
alexpottThis should point to the interface.
SHould be on one line... "Test form submission during a batch operation"
Should be on one line. "Batch operation: Submits form_test_mock_form()."
Comment #39
rpayanmComment #40
filijonka commentedHi
see comment #36 about the @see tag. my fault but it won't work with current parser as @YesCT mentioned.
Comment #41
ianthomas_ukMoved the @see back to an inline comment but now pointing to the interface. Restored a line of the comment that had gone missing.
Comment #42
ianthomas_ukThere's also a single mention of drupal_prepare_form() in a comment which we may as well fix here (the other form functions have already been removed).
Comment #43
prashant.cPatch given in #42 applying succesfully and removing all the instances of drupal_form_submit() from
/core/includes/batch.inc:
./core/includes/install.core.inc:
./core/includes/install.core.inc:
./core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php:
./core/modules/system/tests/modules/batch_test/batch_test.module:
./core/modules/system/src/Tests/Batch/ProcessingTest.php:
./core/modules/system/src/Tests/Batch/ProcessingTest.php:
and also removing instances of drupal_prepare_form().
Comment #44
rpayanmLooks fine for me.
Comment #45
alexpottThis issue is a prioritized change (deprecated code removal) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed ff41283 and pushed to 8.0.x. Thanks!
Fixed on commit.