Hello,

I just updated this morning and now get these errors:

Notice: Undefined index: phone in addressfield_format_phone_generate() (line 36 of....addressfield_phone/plugins/format/phone.inc)
Notice: Undefined index: extension in addressfield_format_phone_generate() (line 46 of....addressfield_phone/plugins/format/phone.inc).
Notice: Undefined index: mobile in addressfield_format_phone_generate() (line 56 of...addressfield_phone/plugins/format/phone.inc).
Notice: Undefined index: fax in addressfield_format_phone_generate() (line 66 of...addressfield_phone/plugins/format/phone.inc).

Comments

basillic’s picture

Title: Getting two errors with latest update » Undefined index in addressfield_format_phone_generate()
StatusFileSize
new1.87 KB

This patch should fix these errors.

ashopin’s picture

Thanks, the notices are gone.

avo webworks’s picture

The patch failed
Hunk #1 FAILED at 33.
Hunk #2 FAILED at 43.
Hunk #3 FAILED at 53.
Hunk #4 FAILED at 63.
4 out of 4 hunks FAILED

tucho’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new2.09 KB
new2.12 KB

If you install the module and activate de addressfield_phone plugin, the user can complete all the phone types.

But if you select some of the types and then deselect them, leaving all the types deselected, the fields are not shown at the form, unless you select all of them.

I attached a patch and an interdiff with the correction of this bug.

jcisio’s picture

Status: Needs review » Needs work
+++ b/plugins/format/phone.inc
@@ -43,7 +43,7 @@ function addressfield_format_phone_generate(&$format, $address, $context = array
-    if ($settings['extension'] || !$settings) {
+    if (empty($settings) || !empty($settings['extension'])) {

I don't understand why the order is inverted. Doesn't the following work, too? It is a minimal change (replace "$a" with "!empty($a)").

if (!empty($settings['extension']) || !$settings) {

tucho’s picture

You're right.

I have just copied the order from the previous patch. It will work too if we mantain the original order of the conditions.

But the $settings variable may not always be defined, so we need to check it's existence with empty($settings) instead of !$settings

Another way to avoid this posibility is initializing the $settings variable, for example, at line 31 of the file plugins/format/phone.inc as $settings = array();.

I think that the second choice makes a smaller patch. If you agree, I can update the patch with these two changes.

fchandler’s picture

This says 7.x-1.x-dev but am getting the message in 7.x-1.2. I am not really a php person, so will this patch work on the 7.x-1.2 release?
Upon further investigation, It does not happen on my live site - D7.37, MySQL 5.5.32, php5.3.13, Apache/2, but does on my local dev site - D7.37, MySQL 5.5.43-0ubuntu0.14.04.1, php5.5.9-1ubuntu4.9, Apache/2.4.7 (Ubuntu). All modules up to date.

fchandler’s picture

Again, will this patch work on the 7.x-1.2? What is an interdiff? What do I use?

As it turns out, I am getting this error on the live site. I just have error messages turned off. The fields show, and I am just assuming they are collecting data correctly.
D7.37, Drupal commerce 7.x-1.11, Address field 7.x-1.1, Address Field Phone 7.x-1.2, MySQL 5.5.32, php5.3.13, Apache/2, All modules are up to date.

tucho’s picture

@fchandler right now, the dev version is the same code of the latest release, so the patch should apply.

If you want to apply the patch, you can read some info here.

LukM’s picture

Has this patch been committed to the dev version yet?
As a noob, I have no idea how to patch, and spent hours downloading programs and trying to figure out how that works, but couldn't get it right. :-(
Sorry.

fchandler’s picture

Got the patch applied and the message stopped. Unchecked all phone field check boxes, all appear. Check specific phone fields and only those appear. Patch #4 works for me. Did not do anything with the interdiff, except to look at it and see the difference.
D7.37
Address Field 7.x-1.1
Address Field Phone 7.x-1.2
Drupal Commerce 7.x-1.11

Arne Slabbinck’s picture

Patch #4 fixed and got rid of the notices for me!

D7.41
Address Field 7.x-1.1
Address Field Phone 7.x-1.2
Drupal Commerce 7.x-1.11

jcisio’s picture

roy_k’s picture

I had this errror and solve it by changing the line, for example:

if (empty($settings) || isset($settings['fax'])) {
...

I added the isset() and it seems to solve it.