Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcingy’s picture

Title: Modernize comment.module forms » Modernize contact.module forms
Component: comment.module » contact.module

Doh!!

marcingy’s picture

Status: Active » Needs review
FileSize
14.21 KB
marcingy’s picture

FileSize
14.2 KB

Extra blank line

tim.plunkett’s picture

Status: Needs review » Needs work

The changes made so far look spot on.

You missed a couple t() in CategoryFormController and MessageFormController.

Also in the other conversions I fixed "Definition of Drupal\..." to be "Contains \Drupal\...", and switched Implements/Overrides to be {@inheritdoc}.

marcingy’s picture

Status: Needs work » Needs review
FileSize
16.19 KB

Fixes up missing t() and the docs.

Status: Needs review » Needs work

The last submitted patch, issue-2072897-5.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
FileSize
16.25 KB

Status: Needs review » Needs work
Issue tags: -FormInterface, -FormBase

The last submitted patch, issue-2072897-7.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +FormInterface, +FormBase

#7: issue-2072897-7.patch queued for re-testing.

marcingy’s picture

FileSize
6.34 KB
16.9 KB

We can also inject user storage

marcingy’s picture

FileSize
16.96 KB

Ok interdiff doesn't want to work nicely added the missing $this->t and fix a docs issue

marcingy’s picture

FileSize
1.55 KB

Ok sorted

Status: Needs review » Needs work
Issue tags: -FormInterface, -FormBase

The last submitted patch, issue-2072897-11.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
Issue tags: +FormInterface, +FormBase

#11: issue-2072897-11.patch queued for re-testing.

jibran’s picture

Status: Needs review » Needs work
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -187,7 +249,7 @@ public function save(array $form, array &$form_state) {
       drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params);

#1889644: Convert drupal_mail_system() to a MailFactory service to allow more flexible replacements is in we can inject mail service.

marcingy’s picture

Status: Needs work » Needs review

Are you sure are as drupal_mail performs alters etc, where as drupal mail service is just the final delivery. Moving back to needs review as I really don't think this is correct and if it is the change notice in the referenced issue needs work because it doesn't explain how to swap things out.

jibran’s picture

11: issue-2072897-11.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 11: issue-2072897-11.patch, failed testing.

andypost’s picture

Issue summary: View changes
Issue tags: +Needs reroll
jayeshanandani’s picture

Assigned: marcingy » jayeshanandani
jayeshanandani’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
16.78 KB
5.58 KB

Patch Rerolled.

Status: Needs review » Needs work

The last submitted patch, 21: 2072897.21.patch, failed testing.

jayeshanandani’s picture

Status: Needs work » Needs review
FileSize
600.47 KB

Updated #21 patch with new modifications.

jayeshanandani’s picture

FileSize
16.78 KB

Ignore last patch. Size got too large. Updation to #21 patch with modifications.

The last submitted patch, 23: 2072897.23.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 24: 2072897.24.patch, failed testing.

jayeshanandani’s picture

FileSize
16.39 KB

New patch without syntax errors and some modifications to #21.

jayeshanandani’s picture

Status: Needs work » Needs review
Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -2,12 +2,14 @@
     /**
      * @file
    - * Definition of Drupal\contact\CategoryFormController.
    + * Contains Drupal\contact\CategoryFormController.
      */
    

    Contains \Drupal\... with a leading backslash.

  2. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -2,12 +2,14 @@
    +use Drupal\Core\Config\ConfigFactory;
    

    You should be using ConfigFactoryInterface now everywhere in this patch in use, type hints and documentation.

  3. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -15,20 +17,46 @@
     
       /**
    -   * Overrides Drupal\Core\Entity\EntityFormController::form().
    +   * The configuration storage.
    +   *
    +   * @var \Drupal\Core\Config\ConfigFactory
    +   */
    +  protected $configStorage;
    +
    

    This is misnamed.. should be something like $contactSettings and @var is \Drupal\Core\Config\Config.

  4. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -15,20 +17,46 @@
    +   * Constructs a new ConfigImportForm.
    

    Wrong class name, copy & pasted from somewhere.

  5. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -15,20 +17,46 @@
    +   * @param \Drupal\Core\Config\ConfigFactory $config_storage
    +   *   The configuration storage.
    +   */
    +  public function __construct(ConfigFactory $config_storage) {
    

    Variable name and description is wrong, this is $config_factory, not $config_storage.

  6. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -101,29 +129,39 @@ public function save(array $form, array &$form_state) {
             ->save();
         }
     
    +
         $form_state['redirect_route']['route_name'] = 'contact.category_list';
    +    $form_state['redirect'] = 'admin/structure/contact';
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function delete(array $form, array &$form_state) {
    +    $form_state['redirect'] = 'admin/structure/contact/manage/' . $this->entity->id() . '/delete';
    +
       }
     
    

    All those changes should be removed.

  7. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -2,15 +2,21 @@
      * @file
    - * Definition of Drupal\contact\MessageFormController.
    + * Contains Drupal\contact\MessageFormController.
      */
    

    Same here, leading \ before Drupal.

  8. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -2,15 +2,21 @@
    +use Drupal\Core\Entity\EntityFormControllerNG;
    

    This class no longer exists, remove the use.

  9. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -25,9 +31,69 @@ class MessageFormController extends ContentEntityFormController {
    +  /**
    +   * The configuration storage.
    +   *
    +   * @var \Drupal\Core\Config\ConfigFactory
    +   */
    +  protected $configStorage;
    

    Same as above, $contactSettings...

  10. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -25,9 +31,69 @@ class MessageFormController extends ContentEntityFormController {
    +  public function __construct(LanguageManager $language_manager, ConfigFactory $config_storage, FloodInterface $flood, UserStorageControllerInterface $user_storage) {
    

    Same here with configuration storage, this is the factory. Also, LanguageManagerInterface instead of LanguageManager.

  11. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -25,9 +31,69 @@ class MessageFormController extends ContentEntityFormController {
       public function form(array $form, array &$form_state) {
    +
         $user = \Drupal::currentUser();
         $message = $this->entity;
    

    This should use $this->currentUser().

  12. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -136,15 +201,15 @@ public function preview(array $form, array &$form_state) {
       public function save(array $form, array &$form_state) {
    -    $user = \Drupal::currentUser();
     
    +    $user = \Drupal::currentUser();
    

    Also here.

  13. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -211,12 +276,15 @@ public function save(array $form, array &$form_state) {
    +    if ($message->isPersonal() && $user->hasPermission('access user profiles')) {
    +      $uri = $message->getPersonalRecipient()->uri();
           $form_state['redirect_route'] = $message->getPersonalRecipient()->urlInfo();
    +      $form_state['redirect'] = array($uri['path'], $uri['options']);
         }
    

    $uri/$form_state['redirect'] should also be removed.

jayeshanandani’s picture

Status: Needs work » Needs review
FileSize
16.06 KB
7.19 KB

Made all improvements as per comment #29. Uploading patch and interdiff for review.

The last submitted patch, 27: 2072897.27.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 30: 2072897.29.patch, failed testing.

Berdir’s picture

  1. +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
    @@ -140,28 +140,16 @@ public function save(array $form, array &$form_state) {
    -
    -    $form_state['redirect_route']['route_name'] = 'contact.category_list';
    -    $form_state['redirect'] = 'admin/structure/contact';
    -  }
    

    Now you removed too much, the redirect_route is still needed.

  2. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -59,9 +58,9 @@ class MessageFormController extends ContentEntityFormController {
        *   The language manager.
        * @param \Drupal\Core\Config\ConfigFactory $config_storage
        *   The configuration storage.
    

    The documentation here also needs to be udated.

  3. +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
    @@ -94,7 +93,7 @@ public static function create(ContainerInterface $container) {
       public function form(array $form, array &$form_state) {
     
    -    $user = \Drupal::currentUser();
    +    $user = \Drupal::$this->currentUser();
         $message = $this->entity;
         $form = parent::form($form, $form_state, $message);
         $form['#attributes']['class'][] = 'contact-form';
    @@ -205,7 +204,7 @@ public function preview(array $form, array &$form_state) {
    
    @@ -205,7 +204,7 @@ public function preview(array $form, array &$form_state) {
        */
       public function save(array $form, array &$form_state) {
     
    -    $user = \Drupal::currentUser();
    +    $user = \Drupal::$this->currentUser();
         $language_interface = \Drupal::languageManager()->getCurrentLanguage();
    

    Without \Drupal, just $this->currentUser().

jayeshanandani’s picture

Status: Needs work » Needs review
FileSize
3.13 KB
16.07 KB

Update to #30 patch. Made modifications as per review on #33.

Status: Needs review » Needs work

The last submitted patch, 34: 2072897.34.patch, failed testing.

jorgegc’s picture

Issue tags: +Needs reroll

Patch in #34 no longer applies. Tagging as needs reroll.

willieseabrook’s picture

Issue tags: +TUNIS_2014_MARCH
inket’s picture

Assigned: jayeshanandani » inket

Hasn't been touched in 2 weeks. I'll work on it. :)

inket’s picture

FileSize
16.05 KB

This patch applies cleanly at commit 0e6c631

inket’s picture

Assigned: inket » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 39: new_patch.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
FileSize
3.21 KB
15.97 KB

rerolled, and UserStorageController -> UserStorage rename.

andypost’s picture

  1. +++ b/core/modules/contact/src/CategoryForm.php
    @@ -16,20 +18,46 @@
    +  public function __construct(ConfigFactoryInterface $config_factory) {
    +    $this->contactSettings = $config_factory->get('contact.settings');
    ...
    -    $default_category = \Drupal::config('contact.settings')->get('default_category');
    +    $default_category = $this->contactSettings->get('default_category');
    

    Use $this->config(), no reason for injection

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -53,15 +87,18 @@ public function __construct(EntityManagerInterface $entity_manager, FloodInterfa
    +      $container->get('config.factory'),
    
    @@ -168,15 +205,14 @@ public function preview(array $form, array &$form_state) {
    +    $user = $this->currentUser();
    

    suppose $this->config() should be used as provided by base class

herom’s picture

FileSize
5.26 KB
14.73 KB

fixed #43.

sun’s picture

Status: Needs review » Needs work

Looks good -- only two small issues:

  1. +++ b/core/modules/contact/src/CategoryForm.php
    @@ -93,33 +93,33 @@ public function validate(array $form, array &$form_state) {
    +    $contactSettings = $this->config('contact.settings');
    ...
    -    $contact_config = \Drupal::config('contact.settings');
    

    Local variables should be $lower_underscored.

    Not sure why $contact_config is touched here at all?

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -2,16 +2,19 @@
     namespace Drupal\contact;
     
    +
     use Drupal\Component\Utility\String;
    

    Extraneous newline.

herom’s picture

Status: Needs work » Needs review
FileSize
1.64 KB
14.7 KB

thanks for review. fixed.

tim.plunkett queued 46: 2072897-46.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 46: 2072897-46.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
FileSize
14.06 KB
sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks.

andypost’s picture

+1 rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://www.drupal.org/files/issues/2072897-49.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14398  100 14398    0     0  14638      0 --:--:-- --:--:-- --:--:-- 14797
error: patch failed: core/modules/contact/src/CategoryForm.php:43
error: core/modules/contact/src/CategoryForm.php: patch does not apply
error: patch failed: core/modules/contact/src/MessageForm.php:11
error: core/modules/contact/src/MessageForm.php: patch does not apply
er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
13.82 KB

Rerolled the patch, but have doubt following line:

-    $sender = clone $this->entityManager->getStorage('user')->load($user->id());
+    $sender = clone $this->userStorage->load($user->id());

Please review.

Status: Needs review » Needs work

The last submitted patch, 53: drupal8-2072897-53.patch, failed testing.

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
13.6 KB

Declared $languageManager once.

Status: Needs review » Needs work

The last submitted patch, 55: drupal8-2072897-55.patch, failed testing.

herom’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.61 KB
11.94 KB

re #53: yes, keeping the $userStorage property wasn't necessary. removed.
Also fixed the reroll issues, and a new "t()" call.

tim-e’s picture

Status: Needs review » Reviewed & tested by the community
larowlan’s picture

+1 rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 40fbf6b and pushed to 8.x. Thanks!

+++ b/core/modules/contact/src/MessageForm.php
@@ -38,7 +38,7 @@ class MessageForm extends ContentEntityForm {
   /**
    * The language manager service.
    *
-   * @var \Drupal\Core\Language\LanguageManagerInterface
+   * @var \Drupal\Core\Language\LanguageManager
    */
   protected $languageManager;

Reverted this change on commit. This should be typehinted to the interface.

  • alexpott committed 40fbf6b on 8.x
    Issue #2072897 by jayeshanandani, marcingy, herom, er.pushpinderrana,...

Status: Fixed » Closed (fixed)

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