-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-20599 Identify a separate public files directory from the private one #10513
Conversation
CRM/Utils/File.php
Outdated
@@ -596,6 +596,25 @@ public static function baseFilePath() { | |||
} | |||
return $_path; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious on the web, but seems like the syntax check detected a trailing whitespace on this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've fixed it.
@herbdool, I like the idea of being able to separate the public/private data dirs. A couple things that stick out:
Have you noticed 313a57a (#10511) - which was merged for 4.7.21 around the same time that you opened this PR? This might be an alternative -- ie allowing you to (optionally) set the
However, it would need similar updates for the |
@totten My initial PR was mostly to start the conversation so I hadn't really thought about some of this--thanks for bring up the issues. Perhaps Then if it becomes optional then we might want to skip it in the installers. I think being able to set [civicrm.files] in settings is a good option, but I found that it doesn't help with separating public and private since IIRC we'd still need a way to differentiate things that need to be private while allowing things like the CKEditor generated js files to be stored in public directories. So maybe we'd still want a [civicrm.publicfiles] and be able to set that as well? As an alternative to this constant. |
diff --git a/Civi/Core/Paths.php b/Civi/Core/Paths.php
index 718b4bc..8784027 100644
--- a/Civi/Core/Paths.php
+++ b/Civi/Core/Paths.php
@@ -35,10 +35,16 @@ class Paths {
return \CRM_Core_Config::singleton()->userSystem->getCiviSourceStorage();
})
->register('civicrm.files', function () {
return \CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
})
+ ->register('civicrm.private', function () {
+ return array(
+ 'path' => fixmeCalculatePrivatePath(),
+ 'url' => '**INVALID-URL**', // URL for private folder would be nonsensical.
+ );
+ })
->register('cms', function () {
return array(
'path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(),
'url' => \CRM_Utils_System::baseCMSURL(),
);
|
Not pedantic at all! :) I keep referring back to a list here https://civicrm.org/advisory/civi-sa-2014-001-risk-information-disclosure which identified four directories which need to be "private": configAndLogDir | Prohibit all web access | determined by templateCompileDir Maybe Civi would need to stop using CIVICRM_TEMPLATE_COMPILEDIR to figure out configAndLogDir, etc. While imageUploadDir is typically |
When I've encountered this in the past, I simply disable the check in |
So it makes sense to create a [civicrm.private] instead, but I think it'll mean that there will be an issue because of how [civicrm.file] is by default being determined by CIVICRM_TEMPLATE_COMPILEDIR which might be have [civicrm.private] in its path (or even an explicit path that's private). Shouldn't we also change how getDefaultFileStorage() and baseFilePath() work? Using the compile directory, which needs to be private, to set the public file path won't work. |
(Also ping @xurizaemon @kcristiano since you guys have been talking about similar issues.) |
@totten Great write up and I agree totally with your proposed changes in 3. Would this change make it easier to support CiviCRM multi-site implementations? |
@agileware re: multisite -- yes-ish For me, "multisite" usually refers to "Drupal 7 + CiviCRM; one codebase; several DNS domains; each DNS domain has its own CMS+CRM DBs". As long as the installer provides a suitable copy of "multisite" can mean different things for other orgs/use-cases (with files/URLs/paths/databases/tables wired up differently). I wouldn't expect to make ever permutation drop-in seamless, but IMHO |
@totten thanks mate, yes that's the answer I was looking for. Cheers for that |
@totten I do think #3 can work, but we need to add additional paths and urls for WP. If we base the admin url on @xurizaemon and I did talk about ensuring we bootstrap the CMS as this will allow us to define the urls and paths via CMS functions. I don't believe there has been any movement on this. As phase 1 leaves the existing computations, we'd be fine. we will just need to test and add these options by phase 2. |
I think this is a good approach. So we can already put in civicrm_paths into civicrm.settings.php as per the recent commit as you noted @totten. So we just need to override the old computation if I'm interested in creating a patch for myself so phase 1 works, which I can use as these things shape up. |
Following up on the discussion from [civicrm#10513](civicrm#10513), this converts the proposed constants `CIVICRM_UF_WP_BASEURL` and `CIVICRM_UF_ADMINURL` to variables in the `Paths` system. A few benefits: * Reduces code duplication between `civicrm.php` and `WordPress.php`. * Can construct sub-paths with prettier notation (`Civi::paths()->getUrl('[wp.frontend]/foo.txt')`) * Has options to output relative or absolute URLs * Can expand on `Paths` to provide more inspection/validation Notes: * `CIVICRM_UF_WP_BASEURL` => `wp.frontend.base` * `CIVICRM_UF_ADMINURL` => `wp.backend.base` ---------------------------------------- * CRM-16421: Work to get CiviCRM for WordPress in WordPress' official Repository https://issues.civicrm.org/jira/browse/CRM-16421
@kcristiano I've opened PR's on your repos with some suggested updates for #10214 and #105. In short, they'd use @herbdool Those fallbacks sounds about right. (Note: In those particular cases, we want to know if the admin has explicitly overridden the values, so you'd check for |
@totten I first tried using |
This partially reverts changes made under CRM-19303: * The changes to `getDefaultFileStorage()` are preserved * The changes to `getCiviSourceStorage()` are reverted * To avoid conflicts, `parseDrupalSiteName()` has been split into the older `parseDrupalSiteNameFromRoot()` and the newer `parseDrupalSiteNameFromRequest()`. (IMHO, `parseDrupalSiteNameFromRequest()` is more correct, but `parseDrupalSiteNameFromRoot()` is more compatible with existing deployments). As discussed in [PR civicrm#10513](civicrm#10513 (comment)), we should stop trying so hard to autodetect these things. We'll treat the auto-detection stuff as legacy, and should shift toward a simpler/flatter arrangement which encourages paths/URLs to be stored in `civicrm.settings.php`.
jenkins, test this please |
@totten I've updated the PR. Not sure if this is the approach you prefer now. |
…w for civicrn.settings.extra.php for WP. Create template for civicrm.settings.extra.php. Update install/civicrm.php for all needed params for different common install scenarios. Fix linting issues in civicrm.php. CRM 16421 CRM 17633 - update CRM_Utils_System_WordPress to allow for common install configurations CRM-16421 - Convert constants to `$civicrm_paths` Following up on the discussion from [civicrm#10513](civicrm#10513), this converts the proposed constants `CIVICRM_UF_WP_BASEURL` and `CIVICRM_UF_ADMINURL` to variables in the `Paths` system. A few benefits: * Reduces code duplication between `civicrm.php` and `WordPress.php`. * Can construct sub-paths with prettier notation (`Civi::paths()->getUrl('[wp.frontend]/foo.txt')`) * Has options to output relative or absolute URLs * Can expand on `Paths` to provide more inspection/validation Notes: * `CIVICRM_UF_WP_BASEURL` => `wp.frontend.base` * `CIVICRM_UF_ADMINURL` => `wp.backend.base` ---------------------------------------- * CRM-16421: Work to get CiviCRM for WordPress in WordPress' official Repository https://issues.civicrm.org/jira/browse/CRM-16421 CRM-16421 - Assimilate `civicrm.settings.extra.php` into `civicrm.settings.php` ---------------------------------------- * CRM-16421: Work to get CiviCRM for WordPress in WordPress' official Repository https://issues.civicrm.org/jira/browse/CRM-16421 CRM-17633 merge current master changes to civicrm.settings.php.template
…w for civicrn.settings.extra.php for WP. Create template for civicrm.settings.extra.php. Update install/civicrm.php for all needed params for different common install scenarios. Fix linting issues in civicrm.php. CRM 16421 CRM 17633 - update CRM_Utils_System_WordPress to allow for common install configurations CRM-16421 - Convert constants to `$civicrm_paths` Following up on the discussion from [civicrm#10513](civicrm#10513), this converts the proposed constants `CIVICRM_UF_WP_BASEURL` and `CIVICRM_UF_ADMINURL` to variables in the `Paths` system. A few benefits: * Reduces code duplication between `civicrm.php` and `WordPress.php`. * Can construct sub-paths with prettier notation (`Civi::paths()->getUrl('[wp.frontend]/foo.txt')`) * Has options to output relative or absolute URLs * Can expand on `Paths` to provide more inspection/validation Notes: * `CIVICRM_UF_WP_BASEURL` => `wp.frontend.base` * `CIVICRM_UF_ADMINURL` => `wp.backend.base` ---------------------------------------- * CRM-16421: Work to get CiviCRM for WordPress in WordPress' official Repository https://issues.civicrm.org/jira/browse/CRM-16421 CRM-16421 - Assimilate `civicrm.settings.extra.php` into `civicrm.settings.php` ---------------------------------------- * CRM-16421: Work to get CiviCRM for WordPress in WordPress' official Repository https://issues.civicrm.org/jira/browse/CRM-16421 CRM-17633 merge current master changes to civicrm.settings.php.template
It seems like conversation has died down here. @herbdool and I were discussing issues with the compiled Smarty templates on Pantheon on the Pantheon power users mailing list, and this issue came up. The main problem on Pantheon (or any infrastructure with multiple webservers where the user uploaded files are stored in a network file system) is that writing the compiled templates during a web request is super slow. A Pantheon engineer suggested storing the compiled templates in the "per instance temporary storage" (basically, a local file directory only for that site on that web server - it's NOT a network file system) which could certainly make sense. The problem with doing that is setting While that isn't the main goal of this issue, the patch here appears to solve that problem: it would allow setting pubilc and private files directories that are totally separate from the compiled templates directory! @totten What is need to re-invigorate this PR? |
Ah, sorry, I see now that discussion is going on here: https://lab.civicrm.org/dev/cloud-native/issues/1 :-) |
This might still be the better place to continue the discussion. So I'll take Tim's comments on Gitlab and update the PR. |
I took another look at this to see how we can move this forward. To me it seems we can't change too much in the first phase. @totten mentions here https://lab.civicrm.org/dev/cloud-native/issues/1#note_3124 that part of the change requires changing the boot order. But it's not clear to me if that's backwards-compatible. Tim suggests putting Civi\Core\Paths before CRM_Core_Config_Runtime, but the former relies on |
@herbdool - Of course, we're in the middle of a pretty complex process -- the only way to see if it works is to try. But it seems like a plausible line of investigation. |
I'm going to close this PR as it seems like it's a conversation not something that can be reviewed. I think the conversation can continue while the PR is closed, and reduce workload on PR triagers. Once there is agreement on approach the PR can be re-opened for formatl review |
For where the site isn't using Apache the site builder needs a way to put certain CiviCRM files under a secure, private directory. This can be done by assigning CIVICRM_TEMPLATE_COMPILEDIR to a private path. But there are some CiviCRM files that need to be public (such as generated js files by CKEditor). So this PR proposes a method of assigning a public files path in civicrm.settings.php which is separate from the template compiled directory.
This works in testing. It's a simple but radical change so I'm mostly creating this PR to feel out the waters.