-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Fix loading with alternate packages path (system-level) #16407
Conversation
(Standard links)
|
jenkins, test this please |
@@ -124,7 +124,13 @@ public function register($prepend = FALSE) { | |||
$this->initHtmlPurifier($prepend); | |||
|
|||
$this->_registered = TRUE; | |||
$packages_path = implode(DIRECTORY_SEPARATOR, [$civicrm_base_path, 'packages']); | |||
// The ClassLoader runs before the classes are available. Approximate Civi::paths()->get('[civicrm.packages]'). | |||
if (isset($GLOBALS['civicrm_paths']['civicrm.packages']['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.
Just adds an IF - no change for normal cases
@@ -177,7 +183,12 @@ private function getHtmlPurifierPath() { | |||
// we do this to prevent a autoloader errors with joomla / 3rd party packages | |||
// Use absolute path, since we don't know the content of include_path yet. | |||
// CRM-11304 | |||
$file = dirname(__FILE__) . '/../../packages/IDS/vendors/htmlpurifier/HTMLPurifier/Bootstrap.php'; | |||
if (isset($GLOBALS['civicrm_paths']['civicrm.packages']['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.
ditto
@@ -433,7 +433,7 @@ public static function strtoboolstr($str) { | |||
* the converted string | |||
*/ | |||
public static function htmlToText($html) { | |||
require_once 'packages/html2text/rcube_html2text.php'; | |||
require_once 'html2text/rcube_html2text.php'; |
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.
we have tests on this I believe
@@ -818,6 +818,19 @@ public function coreResourceList($region) { | |||
// Allow hooks to modify this list | |||
CRM_Utils_Hook::coreResourceList($items, $region); | |||
|
|||
// Oof, existing listeners would expect $items to typically begin with 'bower_components/' or 'packages/' | |||
// (using an implicit base of `[civicrm.root]`). We preserve the hook contract and cleanup $items post-hook. |
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.
This is the most complex part of this PR but my take on it is it would fail very broadly if it were going to. I'm pretty sure the new mailing screen would not load if this were broken (it does load)
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.
Quite right - if these things didn't work, then everything would be wrong in... pretty much every screen. It'd be missing jQuery
, etc. A problem would be pretty obvious.
Code makes sense - I did a basic click around on the test site - feels low risk. Merging |
Overview
The configuration option
$civicrm_paths['civicrm.packages']
allows one to specify the local path and remote URL of thepackages
folder. This is not done often, but it is helpful for the composer/D8/git deployment styles. Alas, there are still sundry hard-coded references to thepackages
folder.This fixes some (but not all) references to
packages
. It generally focuses on classes that are used in universal/system-level processes (such as the class-loader).Before
CRM_Core_Resources
,CRM_Core_Smarty
,CRM_Core_IDS
,CRM_Core_ClassLoader
, andCRM_Utils_String
have path references which assume thatcivicrm-packages.git
lives directly under[civicrm.root]/packages
.After
Each of these references has been updated to relax that expectation.
Comments
Generally, it's preferable to either:
packages
and just rely on the include-path (for*.php
files)packages
using the "paths" subsystem (e.g.Civi::paths()->getPath('[civicrm.packages]/foobar')
.However, some files have peculiar issues which make that problematic -- so several of these items required alternative solutions.
This PR is an extracted subset of #16328, which was an exploratory branch aimed at supporting deployment of Civi git repos in D8 via composer. The changes are extracted to make the size of the review more manageable. It's probably best to use this smaller PR to consider topics like regression-risk and general code convention rather than trying to assess the fuller aims of #16328.