- 🇮🇹Italy apaderno Brescia, 🇮🇹
The patch could apply, but its changes are not correct.
+ \Drupal::database()->schema()->changeField('drupalchat_msg', 'uid1', 'uid1', array( 'description' => 'Uid of the sender.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, ));
Since that code is changed, the indentation of the array lines must be corrected too.
- if (!db_index_exists('drupalchat_msg','uid1')) { - db_add_index('drupalchat_msg','uid1',array('uid1')); + if (!\Drupal::database()->schema()->indexExists('drupalchat_msg','uid1')) { + \Drupal::database()->schema()->indexExists('drupalchat_msg','uid1',array('uid1')); }
The existing code is adding an index if it does not exist. The changed code is checking twice if the index exist.
Also, per Drupal coding standards, there must be a space after the commas between function/method arguments.- if (!db_index_exists('drupalchat_msg','uid2')) { - db_add_index('drupalchat_msg','uid2',array('uid2')); + if (!\Drupal::database()->schema()->indexExists('drupalchat_msg','uid2')) { + \Drupal::database()->schema()->addIndex('drupalchat_msg','uid2',array('uid2')); } - if (!db_index_exists('drupalchat_users','uid')) { - db_add_index('drupalchat_users','uid',array('uid')); + if (!\Drupal::database()->schema()->indexExists('drupalchat_users','uid')) { + \Drupal::database()->schema()->addIndex('drupalchat_users','uid',array('uid')); } - if (!db_index_exists('drupalchat_users','session')) { - db_add_index('drupalchat_users','session',array('session')); + if (!\Drupal::database()->schema()->indexExists('drupalchat_users','session')) { + \Drupal::database()->schema()->addIndex('drupalchat_users','session',array('session'));
There are missing spaces after commas.
+ if(!\Drupal::database()->schema()->fieldExists('drupalchat_msg', 'message_id')) { + \Drupal::database()->schema()->addField('drupalchat_msg', 'message_id', array( 'type' => 'varchar', 'length' => 50, 'not null' => TRUE,
Since that code is changed, the last lines must be correctly indented too.
- $attachments['#attached']['library'][] = 'drupalchat/drupalchat-popup'; + $attachments['#attached']['library'][] = 'drupalchat/drupalchat-popup'; }else if($drupalchat_path_visibility == 1 && !(\Drupal::service('router.admin_context')->isAdminRoute())){ - $attachments['#attached']['library'][] = 'drupalchat/drupalchat-popup'; + $attachments['#attached']['library'][] = 'drupalchat/drupalchat-popup';
Since the purpose of this issue removing calls to functions that have been removed, those changes are off-topic. If the lines that call deprecated functions are also correctly formatted, that is correct, but it is not correct to re-format all the existing lines, or this issue would become Fix the warnings/errors reported by PHP_CodeSniffer, for which there is already an open issue.
- Status changed to Needs review
over 1 year ago 10:04am 9 August 2023 - 🇮🇳India sidharth_soman Bangalore
Made changes according to #7.
Please review.