Skip to content
Snippets Groups Projects

[#3428049] Fixed D10.2 error

3 unresolved threads

Closes #3428049

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
70 if (isset($form['add']['existing_storage_name']) && isset($form['add']['existing_storage_name']['#options'])) {
71 foreach ($form['add']['existing_storage_name']['#options'] as $key => $value) {
72 $arguments = $value->getArguments();
73 if ($arguments['@type']->getUntranslatedString() === 'Computed render array') {
74 unset($form['add']['existing_storage_name']['#options'][$key]);
70 // Remove Computed render array field type from "Re-use an existing field".
71 if (isset($form['add']['existing_storage_name']) && isset($form['add']['existing_storage_name']['#options'])) {
72 foreach ($form['add']['existing_storage_name']['#options'] as $key => $value) {
73 $arguments = $value->getArguments();
74 if ($arguments['@type']->getUntranslatedString() === 'Computed render array') {
75 unset($form['add']['existing_storage_name']['#options'][$key]);
76 }
75 77 }
76 78 }
77 79 }
80 elseif (array_key_exists('computed_render_array', $form['add']['new_storage_type'])) {
  • On Drupal 10.3.1, PHP 8.3 I'm getting:

    TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in computed_field_plugin_form_alter() (line 80 of modules/contrib/computed_field_plugin/computed_field_plugin.module). 

    I would add here default $form['add']['new_storage_type'] ?? [].

    Debug shown that this form alter callback called twice:

    • first time $form contains form for field type selection
    • second time - form for a new field label

    Looks like this is a multistep form shares same form id.

  • Please register or sign in to reply
  • 57 57 * @link: https://www.drupal.org/project/drupal/issues/2932273
    58 58 */
    59 59 if ($form_id === 'field_ui_field_storage_add_form') {
  • 70 if (isset($form['add']['existing_storage_name']) && isset($form['add']['existing_storage_name']['#options'])) {
    71 foreach ($form['add']['existing_storage_name']['#options'] as $key => $value) {
    72 $arguments = $value->getArguments();
    73 if ($arguments['@type']->getUntranslatedString() === 'Computed render array') {
    74 unset($form['add']['existing_storage_name']['#options'][$key]);
    70 // Remove Computed render array field type from "Re-use an existing field".
    71 if (isset($form['add']['existing_storage_name']) && isset($form['add']['existing_storage_name']['#options'])) {
    72 foreach ($form['add']['existing_storage_name']['#options'] as $key => $value) {
    73 $arguments = $value->getArguments();
    74 if ($arguments['@type']->getUntranslatedString() === 'Computed render array') {
    75 unset($form['add']['existing_storage_name']['#options'][$key]);
    76 }
    75 77 }
    76 78 }
    77 79 }
    80 elseif (array_key_exists('computed_render_array', $form['add']['new_storage_type'])) {
    • I would recommend to use if instead of elseif here and in the about if statement add return statement. This gives easier code refactor when Drupal 10.2+ will be requirement for this module and we want to drop version check statement as old code:

      // The "if" statement for the old version completely ready
      // for standalone drop in the future code cleanup.
      if (version_check($current, $expected, '<')) {
        // Something very useful for old version.
        return;
      }
      
      if ($something_useful_for_new_version) {
        // ...
      }
      
    • Please register or sign in to reply
  • Thank you @HitchShock for your work! I discovered only one major issue with php type error on php8.3. Also added some minor suggestions. Otherwise the approach for the issue resolving looks similar to what I saw in other contrib modules.

  • Please register or sign in to reply
    Loading