Using the latest dev the following error is being thrown:

Fatal error: Declaration of Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::buildForm() must be compatible with Drupal\Core\Form\FormInterface::buildForm(array $form, Drupal\Core\Form\FormStateInterface $form_state) in /Users/lukasvonblarer/Sites/attribute/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php on line 15

According to https://www.drupal.org/node/2310411 we need to adapt the implementations of the buildForm(), validateForm() and submitForm() methods.

Comments

luksak’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB

The attached patch implements the necessary changes.

hass’s picture

Category: Bug report » Task
Priority: Major » Normal
hass’s picture

Status: Needs review » Needs work

What about form_set_error()?

luksak’s picture

What do you mean?

hass’s picture

In the article you provided are examples for form errors and that these need to be migrated too. There are a lot of form errors in the validation function.

martin107’s picture

There are no occurrences of form_set_error() in the module!

plenty of \Drupal::formBuilder()->setErrorByName function calls but that is appropriate.

$ drush en google_analytics
The following extensions will be enabled: google_analytics
Do you really want to continue? (y/n): y
Drush command terminated abnormally due to an unrecoverable error.                                  [error]
Error: Declaration of Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::buildForm()
must be compatible with Drupal\Core\Form\FormInterface::buildForm(array $form,
Drupal\Core\Form\FormStateInterface $form_state) in
XXXXX/drupal/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php,
line 15

I don't understand #2. I suggest that this issue be advanced to critical am I wrong? The module cannot be installed otherwise, and prevents progress on all other issues.
I can confirm that this patch, does at least do that.

From https://www.drupal.org/node/2310411 There are some issues around

$foo = $form_state->getValue('foo');
$foobar = $form_state->getValue(array('foo', 'bar'));
$form_state->setValue('foo', 'bar');

But those can be dealt with in a non critical issue.

martin107’s picture

Status: Needs work » Needs review
berdir’s picture

Assigned: luksak » Unassigned
StatusFileSize
new7.26 KB

They're not anymore :)

Updated patch converts them to $form_state->setErrorByName().

Status: Needs review » Needs work

The last submitted patch, 8: 2315253-form_state-classed-object-8.patch, failed testing.

berdir’s picture

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

Something was wrong with the patch.

hass’s picture

@Bedir: That looks code wise what I thought about. Let's see if the bot comes back. However it will fail in all cases because there are bugs in the QA bot.

@martin: I do not care every day if D8 DEV version is broken or not. D8 is changing and we need to follow up after core changed. However this does not make anything a bug as it worked. Such upgrades are tasks not bugs. This is not final software. Don't use it in production! You are warned.

Status: Needs review » Needs work

The last submitted patch, 10: 2315253-form_state-classed-object-10.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review

Yeah, tests are exploding because of the randomName() change. I'd suggest to just commit this and do randomName() => randomMachineName() in a different issue or just quickly do it yourself, just needs a search and replace.

hass’s picture

That's also new. I was more on Token and PHP filter errors...

martin107’s picture

@hass -I know this is pre-beta level software. I have worked on other pre-beta contrib modules, which have a mislabelled concept of 'branch' blocker.
It sends a message about the status of the code, that week say, which I like because it draws many eyes to the important issues.

hass’s picture

Status: Needs review » Needs work
Fatal error: Call to undefined method Drupal\Core\Form\FormBuilder::setValue() in modules\google_analytics\src\Form\GoogleAnalyticsAdminSettingsForm.php on line 742
hass’s picture

Status: Needs work » Needs review
StatusFileSize
new8.34 KB

Fixed setValue and a blindFix for Token module (Fully untested).

hass’s picture

Status: Needs review » Fixed

  • hass committed 48a0707 on 8.x-2.x
    Issue #2315253 by Berdir, hass, Lukas von Blarer: $form_state is now a...

  • hass committed d9b7641 on 8.x-2.x
    Issue #2315253: Rename randomMachine() to randomMachineName()
    

  • hass committed a65220a on 8.x-2.x
    Issue #2315253: Rename randomMachine() to randomMachineName()
    
hass’s picture

$form_state->setValue($element, $values); was an incorrect change. Rolling back and follow up in #2318609: Call to undefined method Drupal\Core\Form\FormBuilder::setValue()

Status: Fixed » Closed (fixed)

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

hass’s picture

Status: Closed (fixed) » Active

This seems to require more work.

Fatal error: Cannot use object of type Drupal\Core\Form\FormState as array in modules\google_analytics\src\Form\GoogleAnalyticsAdminSettingsForm.php on line 507

  • hass committed a1930af on 8.x-2.x
    Issue #2315253: $form_state is now a classed object
    
hass’s picture

Status: Active » Fixed

  • hass committed 707d27f on 8.x-2.x
    Issue #2315253: Fix copy&paste bugs
    

Status: Fixed » Closed (fixed)

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

The last submitted patch, 1: 2315253-form_state-classed-object-1.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 17: Issue-2315253-formstate-is-now-a-classed-object.patch, failed testing.

hass’s picture

Status: Needs work » Closed (fixed)