8000 php:boot - When using --level=classloader, propagate the $civicrm_root by totten · Pull Request #228 · civicrm/cv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

php:boot - When using --level=classloader, propagate the $civicrm_root #228

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

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

totten
Copy link
Member
@totten totten commented Nov 27, 2024

Overview

Provide more hints to CRM_Core_ClassLoader::register() about how to setup classloader.

Before

cv php:boot --level=classloader
/*BEGINPHP*/
require_once  '/home/totten/bknix/build/tmpd10/vendor/civicrm/civicrm-core' . "/CRM/Core/ClassLoader.php";
\CRM_Core_ClassLoader::singleton()->register();
/*ENDPHP*/

After

cv php:boot --level=classloader
/*BEGINPHP*/
$GLOBALS["civicrm_root"] = '/home/totten/bknix/build/tmpd10/vendor/civicrm/civicrm-core';
require_once $GLOBALS["civicrm_root"] . "/CRM/Core/ClassLoader.php";
\CRM_Core_ClassLoader::singleton()->register();
/*ENDPHP*/

Comments

This complements civicrm-core#31512. The general idea is this:

  • When booting, you need to find the vendor/autoload.php.
  • If the site-build has symlinks, then you'd like to search for vendor/autoload.php based on the nominal path (pre-symlink) rather than the real path (post-symlink).
  • We find the nominal path based on the declared $civicrm_root.
  • However, when using eval(cv php:boot --level=classloader), the receiver doesn't load civicrm.settings.php. So the receiver doesn't get $civicrm_root. So we cannot use it as a reference-point to search for vendor/autoload.php.
  • But if if we send a copy of $civicrm_root, then the receiver can use it to search for vendor/autoload.php.

This complements civicrm-core#31512. The general idea is this:

* When booting, you need to find the `vendor/autoload.php`.
* If the site-build has symlinks, then you likely to search for `vendor/autoload.php`
  based on the *nominal* path (pre-symlink) rather than the *real* path
  (post-symlink).
* We find the nominal path based on the declared `$civicrm_root`.
* However, using `--level=classloader`, we don't have `civicrm.settings.php`, so we
  don't have `$civicrm_root` declared. So we cannot use it to search for `vendor/autoload.php`.
* But if we provide a copy of `$civicrm_root` in the boots-script, then the search
  for `vendor/autoload.php` can proceed.
@totten totten merged commit 4e923f5 into civicrm:master Nov 27, 2024
1 check passed
@totten totten deleted the master-classloader-root branch November 27, 2024 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0