First off, thank you so much for this module. It does exactly what I need.

I do have an error message that is showing the following on my page.

Notice: Undefined index: module in faq_ask_form_faq_node_form_alter() (line 337 of /home/xxxx/xxxx/sites/all/modules/faq_ask/faq_ask.module).

I installed and then reinstalled your module and my first installation did not show this.

Everything else seems to functioning as it should. Any ideas on how to remove this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stenjo’s picture

Category: support » bug

I believe this is a small bug as the code does not check for the existence of the category field enabled in the ask a question box.
Have you configured the module properly and it is working the way you are expecting otherwise?

Vanguardian’s picture

Thanks for the response.

Yes, other than that error displaying on pages using the module, everything else is working properly.

stenjo’s picture

I'm a little curious though... The statements that causes the notice is determining if the Taxonomy module is in place and that the fields are modified to not be too big for the column in which the question block is placed.
When writing the code I was sure this is the way of determining if the taxonomy module is loaded and that the fields from that module is displayed.
I'm wondering if you could do me a favour and add the following line just above line 336 in the faq_ask.module file:

	  drupal_set_message('<pre>' . print_r($fields, TRUE) . '</pre>');

- and then post whatever is displayed in your notice field here?
If nothing else it will help me understand what is different with your installation.

The notice will go away if you change the line at 337 from

        if ($properties['display']['default']['module'] != 'taxonomy'

to

        if (isset($properties['display']['default']['module'])
          && $properties['display']['default']['module'] != 'taxonomy'

- also I spotted another small mistake. The whole if-statement should have been enclosed in a set of "{}".

Vanguardian’s picture

Thanks,

After changing line 337 like you recommended, the error stopped showing on the main page. However, this error shows after a user submits a question.

Notice: Undefined index: module in _faq_ask_get_terms() (line 579 of /home/xxxxx/xxxxx/sites/all/modules/faq_ask/faq_ask.module).

Again, everything seems to work as it should otherwise.

Here is the response when the code was added to line 336

Array
(
    [body] => Array
        (
            [label] => Answer
            [widget] => Array
                (
                    [weight] => 31
                    [type] => text_textarea_with_summary
                    [module] => text
                    [active] => 1
                    [settings] => Array
                        (
                            [rows] => 20
                            [summary_rows] => 5
                        )

                )

            [settings] => Array
                (
                    [text_processing] => 1
                    [display_summary] => 1
                    [user_register_form] => 
                )

            [display] => Array
                (
                    [default] => Array
                        (
                            [label] => above
                            [type] => text_default
                            [weight] => 0
                            [settings] => Array
                                (
                                )

                            [module] => text
                        )

                    [teaser] => Array
                        (
                            [label] => above
                            [type] => text_summary_or_trimmed
                            [weight] => 0
                            [settings] => Array
                                (
                                    [trim_length] => 600
                                )

                            [module] => text
                        )

                )

            [required] => 0
            [description] => 
            [default_value] => 
            [id] => 43
            [field_id] => 2
            [field_name] => body
            [entity_type] => node
            [bundle] => faq
            [deleted] => 0
        )

    [field_term] => Array
        (
            [label] => Select Ask Doc to verify
            [widget] => Array
                (
                    [weight] => 32
                    [type] => options_buttons
                    [module] => options
                    [active] => 1
                    [settings] => Array
                        (
                        )

                )

            [settings] => Array
                (
                    [user_register_form] => 
                )

            [display] => Array
                (
                    [default] => Array
                        (
                            [label] => hidden
                            [type] => hidden
                            [weight] => 1
                            [settings] => Array
                                (
                                )

                        )

                    [teaser] => Array
                        (
                            [label] => hidden
                            [type] => hidden
                            [weight] => 0
                            [settings] => Array
                                (
                                )

                        )

                )

            [required] => 0
            [description] => 
            [default_value] => 
            [id] => 44
            [field_id] => 14
            [field_name] => field_term
            [entity_type] => node
            [bundle] => faq
            [deleted] => 0
        )

)
stenjo’s picture

Yes, that is the same kind of problem really.
Does not seem to be the case that the 'module' property of the display settings of all fields are defined. Do not know why, but a similar fix as the one in #3 will take care of it.

Change line 578 from

    if ($properties['display']['default']['module'] != 'taxonomy')

to

    if (isset($properties['display']['default']['module']) && $properties['display']['default']['module'] != 'taxonomy')

Vanguardian’s picture

Thanks so much, seems to be working perfectly now.

Thanks again for a great module and valuable prompt quality support.

lilbebel’s picture

Hi there,

I followed the instructions as above. However, when I added the new code to 578, my long array code notice didn't go away. I have attached screenshots of my code alterations. Do you know why it may not be working for me?

Thanks,

M

stenjo’s picture

when I added the new code to 578, my long array code notice didn't go away.

What error message is that?
Are you able to provide a screenshot of that too?
The code looks right...

lilbebel’s picture

Sorry, error is not the correct word. I am receiving the same response code as vanguardian posted above. Mine didn't go away though.

stenjo’s picture

That's the thing. I do not get what notice message you are getting. Can you copy and paste the notice into this thread please?
Vanguardian is referring to two different notices:
Notice: Undefined index: module in faq_ask_form_faq_node_form_alter() (line 337 of /home/xxxx/xxxx/sites/all/modules/faq_ask/faq_ask.module).
and
Notice: Undefined index: module in _faq_ask_get_terms() (line 579 of /home/xxxxx/xxxxx/sites/all/modules/faq_ask/faq_ask.module).
I am not able to see how either the line numbers or the notices can possibly be identical when the code change is applied the way your screenshots indicates.

lilbebel’s picture

Array
(
[body] => Array
(
[label] => Body
[widget] => Array
(
[type] => text_textarea_with_summary
[settings] => Array
(
[rows] => 20
[summary_rows] => 5
)

[weight] => -4
[module] => text
)

[settings] => Array
(
[display_summary] => 1
[text_processing] => 1
[user_register_form] =>
)

[display] => Array
(
[default] => Array
(
[label] => hidden
[type] => text_default
[weight] => 0
[settings] => Array
(
)

[module] => text
)

[teaser] => Array
(
[label] => hidden
[type] => text_summary_or_trimmed
[settings] => Array
(
[trim_length] => 600
)

[module] => text
[weight] => 0
)

)

[required] =>
[description] =>
[id] => 13
[field_id] => 2
[field_name] => body
[entity_type] => node
[bundle] => faq
[deleted] => 0
[default_value] =>
)

[field_language_term] => Array
(
[label] => Language Term
[widget] => Array
(
[weight] => 1
[type] => options_select
[module] => options
[active] => 1
[settings] => Array
(
)

)

[settings] => Array
(
[user_register_form] =>
)

[display] => Array
(
[default] => Array
(
[label] => hidden
[type] => hidden
[weight] => 1
[settings] => Array
(
)

)

[teaser] => Array
(
[type] => hidden
[label] => above
[settings] => Array
(
)

[weight] => 0
)

)

[required] => 1
[description] =>
[default_value] =>
[id] => 75
[field_id] => 46
[field_name] => field_language_term
[entity_type] => node
[bundle] => faq
[deleted] => 0
)

)

stenjo’s picture

Looks like you have not removed the debugging line I suggested. Does line 336 in the faq_ask.module file look something like this:

	  drupal_set_message('<pre>' . print_r($fields, TRUE) . '</pre>');

If so, remove the code and you should be OK.

/Sten

lilbebel’s picture

Above is the code I get and it doesn't go away when I add 'if (isset($properties['display']['default']['module']) && $properties['display']['default']['module'] != 'taxonomy')' to line 578.

M

lilbebel’s picture

Hi there,

I removed that line as you suggested. The long code has gone but now I have a red box warning saying 'Notice: Undefined index: module in faq_ask_form_faq_node_form_alter() (line 337 of /home5/tsmacade/public_html/sites/all/modules/faq_ask/faq_ask.module).'

M

stenjo’s picture

Yes. See my comment #12. I missed from your screenshot of the first codechange that you still had the debugging code in place. Remove or comment out line 336 and you will be fine.

lilbebel’s picture

I tried both removing the line and un-commenting it but the long code has gone and the red error box remains 'Notice: Undefined index: module in faq_ask_form_faq_node_form_alter() (line 338 of /home5/tsmacade/public_html/sites/all/modules/faq_ask/faq_ask.module).'

stenjo’s picture

Ok, so how does your lines at 335 - 345 in the file /sites/all/modules/faq_ask/faq_ask.module look now?

lilbebel’s picture

This is a screenshot of my code now.

lilbebel’s picture

Thanks for all this help by the way!

stenjo’s picture

Yes, now the change I suggested in my comment #3 is gone from your code. Please insert the isset($properties['display']['default']['module']) piece that you are missing, and you will be OK.
I'll make sure to update dev with these modifications some time during the weekend.

lilbebel’s picture

Sorry, I'm not a PHP expert. On exactly which line should I insert this code? Will it be replacing something that exists there already or will it be in addition to?

stenjo’s picture

Assigned: Unassigned » stenjo
Status: Active » Fixed

This is now fixed in the latest dev. Should be available for download tomorrow.

lilbebel’s picture

Thanks!

Status: Fixed » Closed (fixed)

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

alansch’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review

I'm going to have to re-open this issue. The same error is thrown in line 276...

Notice: Undefined index: module in faq_ask_form_faq_node_form_alter() (line 276 of /.../sites/all/modules/faq_ask/faq_ask.module)

From the .info file,

; Information added by drupal.org packaging script on 2013-09-30
version = "7.x-1.0-alpha1+4-dev"
core = "7.x"
project = "faq_ask"
datestamp = "1380577880"

And, of course, the same fix as the others. Line 276 becomes

      if (   isset($properties['display']['default']['module'])
          && $properties['display']['default']['module'] == 'taxonomy' && isset($form[$name])) {
       hide($form[$name]);                              // Hide form if it is a taxonomy field
       $form[$name][$language]['#required'] = FALSE;    // If hidden, then do not expect it to be required
      }
kaizerking’s picture

#25 fixed this

Colin @ PCMarket’s picture

#25 fixed the error on Line 276 for me too.

izmeez’s picture

Looks like the fix was committed on 2012-08-04, https://git.drupalcode.org/project/faq_ask/-/commit/be753ca5

But, I won't change the status and leave it for someone else to confirm.

However, I see there is another possibly related issue #2167395: Undefined index.