Hi all,
Since I needed photo functionality for VCard in my project, I've decided to implement it.
Specifically, the client asked for the VCard to show a photo when opening it with e.g. Outlook.
According to the VCard specification I think this is doable by base64 encoding the photo and having the encoded string in the VCard. I've added a photo field that takes an online URL, encodes it and passes it to the card.

You're welcome to test my patch and provide feedback (see if the VCard shows a photo when you open it with a mail client that supports VCards). I think you have to reinstall the module when you apply this patch though - not sure.

Thanks,
Kyriakos

Comments

cirrus3d’s picture

StatusFileSize
new2.95 KB

Including the patch for the photo functionality here (note this is against 7.x-1.10)

michaelpporter’s picture

Added to 7.11. Thank you.

mattew’s picture

Priority: Normal » Major
Status: Active » Needs work

Hi,

I updated the module this morning, from 1.8 to 1.11, and now I get some errors about photo field :

Undefined property: stdClass::$field_address_vcard_photo in field_sql_storage_field_storage_load() (line 406 of ...\modules\field\modules\field_sql_storage\field_sql_storage.module).
and
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_address_vcard_photo' in 'field list': (the query...) in field_sql_storage_field_storage_write() (line 494 of ...\modules\field\modules\field_sql_storage\field_sql_storage.module).
and
Exception: exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_address_vcard_photo' in 'field list'' in ...\includes\database\database.inc:2171 Stack trace: (...)

I think the problem is that the photo field has been added to the schema but no hook_update has been written to support migration from older versions.

I think it's a major issue because updating the module breaks the vcard creation.

Thanks

michaelpporter’s picture

Assigned: cirrus3d » michaelpporter

Thanks, I will look in to it.

michaelpporter’s picture

StatusFileSize
new500 bytes

Patch to add update hook

cirrus3d’s picture

Lookg good to me - I can't test it right now but I will as soon as I can. Sorry for breaking stuff people :)

mattew’s picture

Wrong name for the hook... should be vcardfield_field_update_7001, I'm right?

michaelpporter’s picture

StatusFileSize
new494 bytes

You are right; working to quickly.

mattew’s picture

I continue to have the same SQL errors. Maybe the update script should update existing vcard fields instances also, or something like that, no?

michaelpporter’s picture

It should update all vcards. I wonder if it did not fire because the version number is the same with the patch. When you ran update.php did you see anything about vcardfield?

mattew’s picture

When i ran updb, I seen the update, it seems to have been processed.
The first patch did not triggered update, as the hook was not properly named.

mattew’s picture

My errors again :

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_address_vcard_photo' in 'field list': (...) in field_sql_storage_field_storage_write() (line 494 of (...)\modules\field\modules\field_sql_storage\field_sql_storage.module).

Exception: exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_address_vcard_photo' in 'field list'' in (...)\includes\database\database.inc:2171 Stack trace: (...)

michaelpporter’s picture

StatusFileSize
new4.41 KB

I had to rework the update, there is no direct update for field schemas.

  • michaelpporter committed 929dd23 on 7.x-1.x
    Issue #2451755 by michaelpporter, cirrus3d, mattew: Add photo...
mattew’s picture

Hi,

I tried to restore my database two times, at the same state as my production environment, and I get another error now :
Notice : Undefined index: photo dans template_preprocess_vcardfield() (ligne 306 dans (...)\sites\all\modules\contrib\vcardfield\vcardfield.module).

(No more database error)

I get this error several times on each page load (even if no vcard is displayed).

It start to be a problem. Maybe you should revert this "photo" field feature until migration from older version work perfectly. No?
I can't use this version of the module and I need to deploy #2453775 fixe. I think I will revert to a previous version.

Thanks

  • michaelpporter committed 81b91a3 on 7.x-1.x
    Issue #2451755 by michaelpporter, mattew: Add photo and middle name...
michaelpporter’s picture

Please try 7.15, if that does not fix it I will revert until I can test more.

mattew’s picture

Now I have two errors when I download a vcard

 Notice: Undefined index: middle_name in vcardfield_create_vcard() (line 384 of (...)\sites\all\modules\contrib\vcardfield\vcardfield.module).
Notice: Undefined index: photo in vcardfield_create_vcard() (line 404 of (...)\sites\all\modules\contrib\vcardfield\vcardfield.module).

Sorry but I don't understand why you commit and release a version which you have not properly tested. That's definitely not professional... Non-stable code should not be released as "Recommended".

And you should properly comment your hook_updates, it should not looks like this :

vcardfield module :
  7001 -   Implements hook_update_N().  Add photo field to table
  7002 -   Implements hook_update_N().  Add photo field to table
  7003 -   Implements hook_update_N().  Add photo field to table

Thanks

michaelpporter’s picture

Tests here have passed. I will add a few more checks in to verify the types of issues you are having.

  • michaelpporter committed 6058323 on 7.x-1.x
    Issue #2451755 by michaelpporter, cirrus3d: Add photo functionality to...
michaelpporter’s picture

I made a few adjustments to the code so this works better for updates.

mattew’s picture

Sorry, I don't have more time to spend on this, I revert on 1.10 and will not update this module anymore.

michaelpporter’s picture

Did you test 7.16? I ran it through many tests here and the errors are gone and middle name is populating.

mattew’s picture

Each time I test your code I have to restore a database backup to work from production data, and it takes time, I've done this several times since 2 days and I'm fed up, maybe I will try later... sorry.

michaelpporter’s picture

Understand, I'm just saying that I trust 7.16 the others were rushed and I know rushed code is bad code. I should not have released until I had time to test as well.

michaelpporter’s picture

Status: Needs work » Closed (cannot reproduce)
michaelpporter’s picture

Status: Closed (cannot reproduce) » Closed (fixed)