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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Change the path of the extension folder: ain't no good
Pages: [1]

Author Topic: Change the path of the extension folder: ain't no good  (Read 994 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Change the path of the extension folder: ain't no good
May 02, 2014, 12:23:44 am
Hi,

One customer has the extension folder under their drupal root. When they upgrade drupal core, the path changes (eg goes from /var/www/drupal-7.41 to /var/www/drupal-7.42) and it then displays error messages about the extension not being available (it still looks at the old path).

I clear cache here and there in panic until I can get it working, but as it's going to happen regularly, we want to have something more controlled and do the needed part of the upgrade script.

What is the cache that contains the absolute path of the extension and how to clear it?

Or is there a way to store a relative path instead of the absolute one?

Slightly more long term, they have started to modify civicrm.setting.php so instead of containing the absolute paths hardcoded, it uses drush functions to find the paths.
   $_civicrm_drupal_root_path = drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/' . drush_get_context('DRUSH_DRUPAL_SITE');

Would it be a valid solution to continue that way and add the extra stuff like:

$civicrm_setting['Directory Preferences']['extensionsDir'] = $_civicrm_conf_path."/files/civicrm/extensions/";

or is this going to be cached anyway and won't solve the problem?

X+
X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Change the path of the extension folder: ain't no good
May 02, 2014, 01:16:53 pm
The extension system's cache is stored in civicrm_cache using the group 'ext' ("select * from civicrm_cache where group_name  = 'ext'"). The spot which defines this cache is CRM_Extension_System::getCache().

It looks like the paths in there are stored as relative values. However, they're relative to some base path -- eg 'extensionsDir'. The dynamic $civicrm_setting seems like a good workaround. Alternatively, if one is managing extensions by hand (without the web-based download/upgrade), then one can put extensions in the "/var/www/drupal-XXX/vendor".

ojkelly

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: Drupal 7
Re: Change the path of the extension folder: ain't no good
March 17, 2015, 03:22:40 pm
Hi,

I've come across this problem too and worked out a kludgey fix. Ultimately I think the extensions mapper needs a little bit of reworking.

My problem is this: our live environment runs across more than one server, each with only access to it's own codebase.

So the following can happen:

civicrm is loaded on webserver1, and the extensions dir's are cached as such:

/srv/webserver1/code/sites/all/civicrm_extensions

The next page is served from webserver2
Webserver2 retrieves the cached extensions and tries to load

/srv/webserver1/code/sites/all/civicrm_extensions

But it does not have permission to read anything outside of
/srv/webserver2/code/sites/all/civicrm_extensions

So it fails.

A patch I'm running at the moment is
Code: [Select]
// line 299 of CRM/Extension/Mapper.php

    $_moduleExtensions = $moduleExtensions;
    $moduleExtensions =  array();
    foreach($_moduleExtensions as $module){
      $moduleExtensions[] = array(
        'prefix' => $module['prefix'],
        'filePath' => preg_replace('#/srv\/bindings/(\w+)#i', '/srv/bindings/' . $_SERVER['USER'], $module['filePath']),
      );

    }

This updates the part of the root path (specifically on pantheon) after $moduleExtensions has either been initialised or read from cache, ensuring on every page request the current server can access the files.

---

We store our extensions in our git repo, which is the cause of this problem for us. If we store them in the Drupal files dir, everything is fine but development is horrid.

The best solution forward to me seems to store the filePath's as relative to the document root, and load them relative to the document root, instead of the server root.

Cheers
Owen

I apologise if necroposting is not a done thing around here, but this is the most relevant thread I've found on this topic searching via the forums and google.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Change the path of the extension folder: ain't no good
March 17, 2015, 07:05:35 pm
There was a similar issue reported a few months ago -- see https://issues.civicrm.org/jira/browse/CRM-15788 . The idea in that patch was that each web-server would have its own cache of extension metadata (i.e. by deriving the $cacheGroup name from a hash of "extensionsDir", "civicrm_root", etc). It might be interesting to see if the same patch works in your use-case.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Change the path of the extension folder: ain't no good

This forum was archived on 2017-11-26.