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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Replacing CRM_Core_Config
Pages: 1 [2]

Author Topic: Replacing CRM_Core_Config  (Read 2317 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Replacing CRM_Core_Config
September 12, 2015, 04:35:18 pm
Yes, the thinking behind domain ID & profile were both around the idea an extension might modify the results - either based on domain or  having a profile for a particular country - such as loading an extension that allows you to revert to the default settings for a particular country - but doesn't actually change your settings.

However, I think the proof of concept extension I did was the only implementation of this - so I think you could be a bit ruthless here. I know I wound myself in knots making sense of it at the time. You probably recall the features model concept of revert was part of the thinking
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Replacing CRM_Core_Config
September 12, 2015, 07:58:23 pm
Cool, that makes sense. I think it's fine to keep the hook -- but for now maybe we can cut out the caching of the hook. It feels a little premature, and it should be a null-op on most systems.

Next up: "doSiteMove()", "civicrm/admin/setting/updateConfigBackend", "bin/migrate/move.php", "drush civicrm-update-cfg", "wp civicrm update-cfg".

I don't claim to fully understand these, but a few things pop out in skimming:

  • There are several clauses which heuristically adjust paths based on CMS conventions. (Yaaay, brittle!)
  • There's some search-and-replace on the non-existent 'url_preferences' and 'directory_preferences' OptionGroups. (There've been one or two hints that these things used to exist... perhaps as predecessors to the URL and Directory setting groups?)
  • There's more "$$foo" stuff than I care for.
  • It deletes a random assortment of cache data and session data.

Based on #2, this has probably been broken since ~v4.1, but (guessing here) the workflow around using it was so convoluted (*ahem* http://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location ) that no one could tell whether (a) the tool was broken or (b) they were using it wrong.

Maybe this is wishful thinking, but... can we just delete this stuff in 4.7? With the refactored CRM_Core_Config, we'll no longer use  config_backend (which has been caching the absolute-paths/absolute-URLs). In their canonical storage (table "civicrm_setting"), the URLs+paths have been stored as relative-paths (unless you specifically pointed outside the normal basepath). I'm struggling to see why this would be needed for a typical migration. Just flush the caches.

To be sure... if you've created a funky file structure (with items outside the normal basepath), then you need to adjust path/URL settings... but if it's a funky structure, then... is it really amenable to simple/predictable conversion? Feels simpler/more predictable for the admin to update or delete the settings directly (via drush or bin/cli.php or SQL or $civicrm_setting or whatever).

But I'm biased.

Would anyone miss it if removed? Has anyone used this successfully since v4.1?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Replacing CRM_Core_Config
September 12, 2015, 08:16:36 pm
I think you can interpret doSiteMove etc as a work-around for breaky-brittleness. It's still the case that it can be hard to move sites from staging to production - but I think as long as you can see moved sites working well, then I don't think those functions need to be part of the solution.

I'm not too sure what the remaining problems are - I just hammer things until something works. Pretty sure in 4.6 that if you enter a relative url for extensions dir it miscalculates the full url unless it is under sites/default/files.

So, I think you can be change the method with extreme prejudice as long as the goal - site moves are smooth (or worst case -  no less smooth!) is respected

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Replacing CRM_Core_Config
September 12, 2015, 08:49:45 pm
Quote from: Eileen on September 12, 2015, 08:16:36 pm
I'm not too sure what the remaining problems are - I just hammer things until something works. Pretty sure in 4.6 that if you enter a relative url for extensions dir it miscalculates the full url unless it is under sites/default/files.

This makes some sense. The code which evaluates the relative path is generally based on figuring things relative to "sites/*/files/civicrm" - it wouldn't know how to adapt things outside that.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: Replacing CRM_Core_Config
September 13, 2015, 01:07:54 pm
"doSiteMove" is used by the Drush command "civicrm-update-cfg".

It's called by Aegir after migrating a site from one directory (platform) to another. That code always gave me headaches. I took the habit of overriding the url/directory settings by hardcoding them in a settings.php file.

In any case, if those settings get calculated at runtime, I will be happy to see it go away :-)
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Replacing CRM_Core_Config
September 14, 2015, 01:23:27 pm
Quote from: mathieu on September 13, 2015, 01:07:54 pm
That code always gave me headaches. I took the habit of overriding the url/directory settings by hardcoding them in a settings.php file.

I think that overriding the settings made doSiteMove() irrelevant/unnecessary... which is consistent with my theory that doSiteMove() simply doesn't work.

A quick tally:

  • Two respected/active devs found it easier to fix the settings directly (rather than fix doSiteMove).
  • One dev (me) says the code in doSiteMove() looks broken.
  • Zero people have spoken up for it. (I reached out to the full civicrm-planning@ to find someone.)
  • Zero tests provide coverage of doSiteMove(). (Understandably - it's basically impossible to test without putting the entire stack into a test harness.)

So... I'll remove it and file a bug against the documentation.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Replacing CRM_Core_Config
September 17, 2015, 12:32:01 am
The handling of relative paths turns out to be a bit confusing. For example:

 * URLs are are computed relative to the web/cms root.
 * File paths are computed relative to the "files/civicrm" folder (err, TEMPLATE_COMPILEDIR)
 * With some settings (imagesUpload{Dir,Url} and extensions{Dir,Url}), you need the URL and path to match. But if they're expressed as relative paths, then they won't look at all the same, and (for Drupal multi-site) the URL won't really be portable.

The only way I could find to make these things clearer while preserving portability was to introduce support for base-variables in paths and URLs. The attached screenshot demonstrates this.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Replacing CRM_Core_Config
September 18, 2015, 02:19:20 pm
The changes have been merged into master.

A side note on test performance -- towards the end of dev on this PR, the test performance seemed to improve (~50min runtimes), which is surprising considering that (a) we've been getting mostly 2hr-4hr runtimes in recent months and (b) I locally benchmarked a couple random pages+tests and didn't see a performance improvement.

Hard to tell if this is causation, an unseen variable, or just wishful thinking. Each is plausible. It'll be interesting to see if we get more 50min runtimes going forward.

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Replacing CRM_Core_Config

This forum was archived on 2017-11-26.