-
-
Notifications
You must be signed in to change notification settings - Fork 88
Changes for Composer #348
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
base: master
Are you sure you want to change the base?
Changes for Composer #348
Conversation
|
I'm just giving some quick reaction (without re-tracing paths) - in no particular order:
|
|
So I'm trying to get my head round this (I'm not familiar with Composer file structures) but if you're going to avoid assumptions about where CivICRM Core is located, then you'll also need to modify this line too:
|
@totten Perhaps you recall that we had wide-ranging discussions (perhaps here before the issue queue was closed?) of why directory traversal won't work reliably in a WordPress environment. FWIW it was the primary reason for building the WP-REST routes to replace tl;dr Only WordPress has canonical knowledge of:
@jackrabbithanna My guess is that ease of configurability on a per site basis is likely to be the most reliable path forward - because generalising about WordPress from a plugin is not the recommended thing to do. |
|
civicrm/civicrm-core#32945 (comment) related to above comment as well. |
I don't think this PR suggests doing that. The aim is to add support for some composer layout. The composer layout may differ from existing layouts, and it appears negotiable, but it is only one, and it does not require a general comprehension of all possible WordPress layouts.
Composer has some canonical file-structures. For example, if one said: Then it would download some archives (like
Additionally, there's a constraint about overlapping folders -- we can move packages, but we shouldn't let them overlap. Alas, the basic/default layout for Civi-WP has three overlapping folders -- what you might call Matryoshka dependencies, e.g. The Matryoshaka layout is kinda handy for zipball/tarball distribution, but it's functionally problematic for In Mark's Which brings us to the current issue. If you have this layout, then you stumble upon a few hardcoded Matryoshka references in PHP. Thus the PR proposes: -require_once CIVICRM_PLUGIN_DIR . 'civicrm/CRM/Core/ClassLoader.php';
+require_once $civicrm_root . 'CRM/Core/ClassLoader.php';If I understand correctly, the theory is that |
|
@totten Thanks for this explanation - I appreciate it 👍 FWIW, by "generalising about WordPress from a plugin" I meant traversing directories in order to find stuff. It's not generally reliable when done from an entry point that is a plugin file, e.g. It's good to see that Composer has relatively predictable file structures and I'm sure that this can be accommodated for This is probably more relevant to the civicrm-core PR, however. My suggestion for the additional change to this PR is still relevant here. |
|
wrt css/js resources, or other static files, I don't think changes need to be made for paths. Those can be put in the correct location, for whatever directory location via the CiviCRM Asset Plugin. I put WP plugins in a "contrib" directory, but this is optional, a choice, not a requirement. The developer of the composer.json can set whatever paths they choose. @christianwach It is also possible to specify file extensions to copy, so perhaps .gif files are included (untested) See the options: https://lab.civicrm.org/dev/civicrm-asset-plugin#options In this way it is possible for the .gif file to be in the plugin directory in the expected location. |
| // Initialize the Class Loader. | ||
| require_once $civicrm_root . 'CRM/Core/ClassLoader.php'; | ||
| CRM_Core_ClassLoader::singleton()->register(); | ||
|
|
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.
@jackrabbithanna Just wondering... perhaps this code could be removed completely? AFAICT the same code is run at the bottom of civicrm.settings.php so I'm not entirely sure why it's being run again.
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 was a little hesitant to remove completely, as its been there for so long. This simply changes the order it happens
|
Any objections to this? I'm marking it as ready for review. Just a simple change of the order that would do no other use cases any harm. |
|
I don't have any strong exceptions, but I would prefer to see this code removed rather than relocated. Are you able to test that alternative @jackrabbithanna ? Less code is always preferable :) |
|
@christianwach .. I tested without that code. it does seem to work on both installation and normal page loads. I am hesitant to remove it, not knowing all possible cases. The purpose of this PR is just to make it composer can work, and the changes in it do make that happen. I trying it out to see how the tests run. |
|
@jackrabbithanna I do agree that we need more testing to remove the code referenced #348 (review) @christianwach I think moving to a separate PR would be a good way to do this? I'll set up some time to test this and #349 . As I don't expect these changes to interfere with the 'typical' existing install methods I suspect we can merge after that. |
|
@kcristiano yeah I put the require Classloader.php, in its new spot. And composer based installation + page loads will work. |
Overview
WIP PR working on https://lab.civicrm.org/dev/wordpress/-/issues/155
Changes to make the plugin work with composer installation.
Assuming removing the ./civicrm directory from the plugin directory, so Core is in vendor.
Technical Details
If the $civicrm_root global variable in the civicrm.settings.php is changed to point to the ./vendor/civicrm/civicrm-core/ directory