twomice / com.joineryhq.activityical

CiviCRM extension: Provides an iCalendar feed of assigned activities per contact
Other
2 stars 13 forks source link

Installation of extention on WP causes critical error #56

Open atluxity opened 1 day ago

atluxity commented 1 day ago

Attempting to install the extention through clicking "Install" in the webgui gives a wordpress critical error.

My environment:

# grep version wp-content/plugins/civicrm/civicrm/civicrm-version.php | head -n 1
  return array( 'version'  => '5.78.4',
# wp core version --allow-root
6.6.2
# wp plugin list --format=table --allow-root
+------------------+----------+--------+---------+----------------+-------------+
| name             | status   | update | version | update_version | auto_update |
+------------------+----------+--------+---------+----------------+-------------+
| akismet          | inactive | none   | 5.3.3   |                | off         |
| civicrm          | active   | none   | 5.78.4  |                | off         |
| civievent-widget | active   | none   | 3.2     |                | on          |
| hello            | inactive | none   | 1.7.2   |                | off         |
+------------------+----------+--------+---------+----------------+-------------+
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

from wp debug.log:

PHP Fatal error:  Uncaught Error: Cannot access protected property Smarty\Smarty::$template_dir in REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/packages/smarty5/Smarty.php:37
Stack trace:
#0 REDATED-WP-DIR/wp-content/uploads/civicrm/ext/com.joineryhq.activityical/activityical.civix.php(99): Smarty->__get()
#1 REDATED-WP-DIR/wp-content/uploads/civicrm/ext/com.joineryhq.activityical/activityical.civix.php(129): _activityical_civix_civicrm_config()
#2 REDATED-WP-DIR/wp-content/uploads/civicrm/ext/com.joineryhq.activityical/activityical.php(62): _activityical_civix_civicrm_install()
#3 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager/Module.php(71): activityical_civicrm_install()
#4 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager/Module.php(39): CRM_Extension_Manager_Module->callHook()
#5 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager.php(296): CRM_Extension_Manager_Module->onPreInstall()
#6 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/api/v3/Extension.php(42): CRM_Extension_Manager->install()
#7 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_install()
#8 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(153): Civi\API\Provider\MagicFunctionProvider->invoke()
#9 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(79): Civi\API\Kernel->runRequest()
#10 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/api/api.php(136): Civi\API\Kernel->runSafe()
#11 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Extensions.php(187): civicrm_api3()
#12 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(646): CRM_Admin_Form_Extensions->postProcess()
#13 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(144): CRM_Core_Form->mainProcess()
#14 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(43): CRM_Core_StateMachine->perform()
#15 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform()
#16 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle()
#17 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(356): HTML_QuickForm_Page->handle()
#18 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(364): CRM_Core_Controller->run()
#19 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(170): CRM_Core_Page_Basic->edit()
#20 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Admin/Page/Extensions.php(110): CRM_Core_Page_Basic->run()
#21 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(338): CRM_Admin_Page_Extensions->run()
#22 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(74): CRM_Core_Invoke::runItem()
#23 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
#24 REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm.php(1231): CRM_Core_Invoke::invoke()
#25 REDATED-WP-DIR/wp-includes/class-wp-hook.php(324): CiviCRM_For_WordPress->invoke()
#26 REDATED-WP-DIR/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#27 REDATED-WP-DIR/wp-includes/plugin.php(517): WP_Hook->do_action()
#28 REDATED-WP-DIR/wp-admin/admin.php(259): do_action()
#29 {main}
  thrown in REDATED-WP-DIR/wp-content/plugins/civicrm/civicrm/packages/smarty5/Smarty.php on line 37
atluxity commented 1 day ago

I dont know what I am doing, but this seemed to fix the imitate issue. Unknown if this is a fix or will break things down the road. Do not trust my code.

https://github.com/twomice/com.joineryhq.activityical/blob/5d9158e8e1db7caf05b5a6dbce1ef906f10513cf/activityical.civix.php#L94

$template = CRM_Core_Smarty::singleton();

$extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';

$currentDirs = $template->getTemplateDir(); // Get the existing template directories

// Check if the current directories are in an array format
if (is_array($currentDirs)) {
    array_unshift($currentDirs, $extDir); // Add the new directory to the beginning of the array
} else {
    $currentDirs = [$extDir, $currentDirs]; // Create an array with the new and old directories
}

// Set the updated template directories
$template->setTemplateDir($currentDirs);

$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
atluxity commented 1 day ago

Oh, and looks like

https://github.com/twomice/com.joineryhq.activityical/blob/5d9158e8e1db7caf05b5a6dbce1ef906f10513cf/activityical.php#L39C1-L46C1

function activityical_civicrm_config(&$config) {
    $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
    $template = CRM_Core_Smarty::singleton();

    // Add the custom plugins directory using the addPluginsDir() method
    $template->addPluginsDir($extRoot . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins');

    _activityical_civix_civicrm_config($config);
}

This no loger gives me errors, but do not think I know what I am doing