CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Problem uploading Contact Image
Pages: [1]

Author Topic: Problem uploading Contact Image  (Read 3976 times)

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Problem uploading Contact Image
August 08, 2010, 07:46:25 pm
I have a strange problem which might be a bug, but I want to post here first in case someone has ideas where to look to resolve.

Nearly-new install of 3.2 (fresh, not upgrade) on Joomla! 1.5.20.

When I create or modify a contact and upload a contact image, the image is successfully uploaded to the right directory, however the image_URL field on the contact record is populated incorrectly, preventing the image from displaying on the contact and I get the warnings below.  The strange thing is that the image_URL field is entirely correct except that the domain name is truncated.  So whereas the image_URL field should be
'http://www.domain.com/media/civicrm/custom/ben_bb97be2105b2c767637bdbfb7e052350.jpg'
it is stored as
'http://www.domain.c/media/civicrm/custom/ben_bb97be2105b2c767637bdbfb7e052350.jpg' (note .com is clipped to .c)

I have verified the CIVICRM_UF_BASEURL is set to http://www.domain.com/administrator/

I tried tracing where the image_URL is being calculated but I'm still a PHP novice and am not familiar enough with the Civi core.

Any ideas how to proceed? ???

Ben


Warnings from View contact:

Warning: getimagesize() [function.getimagesize]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /mnt/data/vhosts/domain.com/httpdocs/administrator/components/com_civicrm/civicrm/CRM/Contact/Form/Contact.php on line 407

Warning: getimagesize(http://www.domain.c/media/civicrm/custom/ben_bb97be2105b2c767637bdbfb7e052350.jpg) [function.getimagesize]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /mnt/data/vhosts/domain.com/httpdocs/administrator/components/com_civicrm/civicrm/CRM/Contact/Form/Contact.php on line 407

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem uploading Contact Image
August 08, 2010, 09:30:59 pm
Are you able to replicate this issue on http://joomla.demo.civicrm.org? If yes please file an issue in jira

Kurund
Found this reply helpful? Support CiviCRM

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 08, 2010, 09:48:57 pm
Nope it's not reproducible on the demo site. 

It's clearly getting the wrong path on my site though.  How would I go about figuring out where the path is being miscalculated?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem uploading Contact Image
August 08, 2010, 10:48:16 pm
Can you check your Image Url: http://drupal.demo.civicrm.org/civicrm/admin/setting/url&reset=1

Kurund
Found this reply helpful? Support CiviCRM

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 09, 2010, 06:49:16 am
My urls are the following:

CiviCRM Resource
http://www.domain.com/administrator/components/com_civicrm/civicrm/

Image URL
http://www.domain.com/media/civicrm/persist/contribute/

Custom CSS
(blank)

Also for completeness' sake here are my Upload directory settings:

Temporary Files
/mnt/data/vhosts/domain.com/httpdocs/media/civicrm/upload/

Images
/mnt/data/vhosts/domain.com/httpdocs/media/civicrm/persist/contribute/

Custom Files
/mnt/data/vhosts/domain.com/httpdocs/media/civicrm/custom/

So it looks like it is uploaded to the "Custom Files" folder, however, this doesn't seem to match with the "Image URL" setting...

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 10, 2010, 08:24:49 pm
Anyone able to point me to the .php file/ block of code where the image_url path is calculated on contact update/save so I can debug from there?

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Problem uploading Contact Image
August 10, 2010, 09:54:01 pm
You wanna have a look at processImageParams method in CRM/Contact/BAO/Contact.php and check what the call to getRelativePath method returns around approx Line No 821.

-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 11, 2010, 08:17:17 pm
Thanks so much Yashoda for the tip.  I have resolved the issue, however, since this isn't reproducible on the demo site I can't submit the ticket to Jira...

In the file CRM/Contact/BAO/Contact.php I traced it down to the line that determines the userFrameworkBaseURL.  Something to do with the trim() method is going wonky (on line 752 for me).

Code: [Select]
$userFrameworkBaseURL = trim( $config->userFrameworkBaseURL,'/administrator/' );
For some reason modified "http://www.domain.com/administrator/" to "http://www.domain.c"

Changing the line of code to use a combination of str_replace and trim like so

Code: [Select]
$userFrameworkBaseURL = trim(str_replace("/administrator/", "", $config->userFrameworkBaseURL));
works properly and produces "http://www.domain.com".  Consequently, image paths are now calculated correctly and images render fine. 

Out of curiosity, any experienced PHPers know why this might happen in my case but not on the Joomla Demo site?

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 11, 2010, 08:18:02 pm
Oops - sorry I misspelled your name Yashodha.  Thanks again!

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Problem uploading Contact Image
August 13, 2010, 07:24:17 am
We 'll investigate and get back to you on this :)

-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Problem uploading Contact Image
August 13, 2010, 08:37:00 am
Code: [Select]
$userFrameworkBaseURL = trim( $config->userFrameworkBaseURL,'/administrator/' );
It seems trim function does NOT behave properly when the domain name ends with .com and instead gets rid of the substring om/administrator/, so it fails for you and NOT demo (where it is .org).

Your fix seems to do the trick, will file an issue.

Thanks for catching this!
Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Problem uploading Contact Image
August 13, 2010, 08:41:00 am
Here is the filed issue :
http://issues.civicrm.org/jira/browse/CRM-6658

-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

zutroyquixote

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Joomla 1.5.23
  • MySQL version: 5.2.3
  • PHP version: 5.2.16
Re: Problem uploading Contact Image
August 13, 2010, 09:04:34 am
Great!  Glad to know this will help the code base.

Is it worth investigating if the trim() method is used on the base URL elsewhere in the code base?  Just in case? 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Problem uploading Contact Image

This forum was archived on 2017-11-26.