Closed agileware-justin closed 4 years ago
Hi @agileware-justin, thanks for testing/reporting. Any chance you could debug this a bit more? Looking at the diff, there were no changes in the classes, just a bit of cleanup.
I did a few tests, here is what I see:
Error: Class 'Civi\FlexMailer\Services' not found in CachedCiviContainer->getCiviFlexmailerApiOverridesService()
(line 839 of [...]/files/civicrm/templates_c/CachedCiviContainer.9bc1fb3141eeeaf45d08bc198ea03a08.php).
That file has:
/**
* Gets the public 'civi_flexmailer_api_overrides' shared service.
*
* @return \Civi\API\Provider\ProviderInterface
*/
protected function getCiviFlexmailerApiOverridesService()
{
return $this->services['civi_flexmailer_api_overrides'] = \Civi\FlexMailer\Services::createApiOverrides();
}
Restoring the legacy autoload fixes the problem:
/**
* Define an autoloader for FlexMailer.
*
* FlexMailer uses the namespace 'Civi\FlexMailer', but the
* autoloader in Civi v4.6 doesn't support this, so we provide
* our own autoloader.
*
* TODO: Whenever v4.6 dies, remove this file and define the
* autoloader in info.xml
*
* @link http://www.php-fig.org/psr/psr-4/examples/
*/
function _flexmailer_autoload($class) {
$prefix = 'Civi\\FlexMailer\\';
$base_dir = __DIR__ . '/src/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists($file)) {
require $file;
}
}
spl_autoload_register('_flexmailer_autoload');
as did deleting the CiviCRM container cache manually, which I could not do using drush (didn't test 'cv'):
rm [...]/files/civicrm/templates_c/CachedCiviContainer*
PR in #62
@agileware-justin Could you test?
I figure that if we leave this in for a few versions, then we can remove it later on (late adopters will be bit, but we could wait 6-12 months before removing it, unless we find a better fix).
@mlutfy thanks for taking time to investigate, reproduce and submit the PR. Can confirm that we used the same fix as https://github.com/civicrm/org.civicrm.flexmailer/pull/62
wp-cli and cv were unusable due to this bug, so good to know rm fixes it. We'll definitely include that in the "clear all cache things" macro.
Good to merge from Agileware's perspective.
Just letting you know that merging PR 53 broke Website & CiviCRM site(s) with Uncaught Error: Class 'Civi\FlexMailer\Services' not found errors:
Clearing CiviCRM cache didn't fix the problem and both the Website and CiviCRM site(s) were both down as a result. Reverting this change brought the site back on-line.
There seems to be a pattern with CiviCRM caching not be able to deal with classes being moved around the file system or simply loaded differently.
Anyway, just letting you know @colemanw @mattwire
Agileware Ref: CIVICRM-1506