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) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.5 Release Testing »
  • [FIXED] -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
Pages: [1]

Author Topic: [FIXED] -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP  (Read 1159 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
[FIXED] -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
July 29, 2014, 11:57:25 pm
Classes are being loaded in 4.5.beta3 by packages/vendor/composer/ClassLoader.php but this doesn't respect Custom PHP as set by the 'customPHPPathDir' configuration parameter.

ClassLoader.php gets its directories from packages/vendor/composer/autoload_namespaces.php which contains ...

Quote
<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
    'Symfony\\Component\\DependencyInjection\\' => array($vendorDir . '/symfony/dependency-injection'),
    'Psr\\Log\\' => array($vendorDir . '/psr/log'),
    'Civi\\' => array($baseDir . '/..', $baseDir . '/tests/phpunit'),
    'CRM_' => array($baseDir . '/..'),
);

If I edit the last line to be ...

Quote
    'CRM_' => array('/my/custom/php/directory', $baseDir . '/..'),
);

... then my custom code is found.

We need to either revert to loading classes the old way, or changing this to respect 'customPHPPathDir'. I also wonder whether this breaks extensions etc that (for better or worse) override class names that are part of Core.
« Last Edit: August 16, 2014, 01:06:44 pm by Coleman Watts »

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 4.5.beta3 -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
August 06, 2014, 05:27:46 am
Can you please file an issue for the same

Kurund
Found this reply helpful? Support CiviCRM

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 4.5.beta3 -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
August 07, 2014, 01:49:21 am
Created issue CRM-15081

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: 4.5.beta3 -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
August 07, 2014, 10:41:15 am
Yes, this was breaking an extension of ours that was attempting to override core files. Thanks for reporting and filing core bug, Ken.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: 4.5.beta3 -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP
August 07, 2014, 04:25:13 pm
PR: https://github.com/civicrm/civicrm-packages/pull/71

I suspect it's an intentional design decision that composer does not to facilitate runtime class-overrides. (Or, put another way, I don't think many folks in the broader PHP community would lift a finger to preserve that anti-pattern.) But we should maintain compatibility with existing overrides.

The PR tells composer to skip autoloading of CRM_* classes -- so the old autoloader (which supports overrides) will handle CRM_*, and the new autoloader (from composer, which doesn't support them) will handle new classes (e.g. Symfony\* and Civi\*).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.5 Release Testing »
  • [FIXED] -CRITICAL- packages/vendor/composer/ClassLoader.php breaks Custom PHP

This forum was archived on 2017-11-26.