Logic Hooks not firing on Shared Host

Hi

Hope someone can help as I have spent hours on this matter researching the internet for an answer.

I am having trouble with my logic_hook not firing on my shared host. I create a cost.php and logic_hook.php under Custom/Modules/AOS_Products. The cost.php just performs a few calculations for the varies custom fields created for the products that I have in the system.

The logic hooks are working fine on my Test machine at home (it’s running wampserver). Apache Version : 2.2.22 PHP Version : 5.3.13 MySQL Version :
5.5.24

I have set the permissions correctly on the shared host and am still not able to resolve the issue please help.

Below is a snippet from the log file where I am receiving the follow error.

Mon Nov 10 09:01:18 2014 [21070][1][DEPRECATED] Formatting correction: AOS_Products->date_entered had formatting automatically corrected. This will be removed in the future, please upgrade your external code
Mon Nov 10 09:01:18 2014 [21070][1][DEPRECATED] Formatting correction: AOS_Products->date_modified had formatting automatically corrected. This will be removed in the future, please upgrade your external code
Mon Nov 10 09:01:18 2014 [21070][1][DEBUG] Hook called: AOS_Products::before_save
Mon Nov 10 09:01:18 2014 [21070][1][ERROR] Unable to load custom logic file: custom/modules/aos_products/cost.php
Mon Nov 10 09:01:18 2014 [21070][1][ERROR] Unable to load custom logic file: custom/modules/aos_products/cost.php
Mon Nov 10 09:01:18 2014 [21070][1][ERROR] Unable to load custom logic file: custom/modules/aos_products/cost.php
Mon Nov 10 09:01:18 2014 [21070][1][ERROR] Unable to load custom logic file: custom/modules/aos_products/cost.php
Mon Nov 10 09:01:18 2014 [21070][1][ERROR] Unable to load custom logic file: custom/modules/aos_products/cost.php
Mon Nov 10 09:01:18 2014 [21070][1][INFO] Get One: |SELECT id_c FROM aos_products_cstm WHERE id_c = ‘189381f4-ae26-c436-df68-53dbe93a4ab4’|

Below is a copy of my logic_hook.php

<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'cost', 'custom/modules/aos_products/cost.php', 'cost', 'cost'); $hook_array['before_save'][] = Array(2, 'subtotal', 'custom/modules/aos_products/cost.php', 'subtotal', 'subtotal'); $hook_array['before_save'][] = Array(3, 'markup', 'custom/modules/aos_products/cost.php', 'markup', 'markup'); $hook_array['before_save'][] = Array(4, 'selling', 'custom/modules/aos_products/cost.php', 'selling', 'selling'); $hook_array['before_save'][] = Array(5, 'sqm', 'custom/modules/aos_products/cost.php', 'sqm', 'sqm'); ?>

Below is a copy of my cost.php

<?php class cost { function cost(&$bean, $event, $arguments) { // calculate item cost $bean->cost = ($bean->cp_lm_c / $bean->width_c); } } class subtotal { function subtotal(&$bean, $event, $arguments) { // calculate item subtotal $bean->subtotcost_c = ($bean->cost + $bean->underfelt_c + $bean->fitters_c); } } class markup { function markup(&$bean, $event, $arguments) { // calculate item markup $bean->markup_c = ($bean->subtotcost_c * $bean->markup_p_c / 100); } } class selling { function selling(&$bean, $event, $arguments) { // calculate item selling $bean->price = ($bean->subtotcost_c + $bean->markup_c + $bean->c_load_c + $bean->lam_fitters_c); } } class sqm { function sqm(&$bean, $event, $arguments) { // calculate item sqm $bean->markup_sqm_c = ($bean->c_load_c + $bean->markup_c); } } ?>

Check the sugar error logs as there must be some sort of error occuring on the shared host. Also which version of php is the shared host using?

Hi they are currently using

Apache version 2.2.24
PHP version 5.4.16
MySQL version 5.1.73-cll

you haven’t specified when the the hook should fire, I assume in this case it should be before save

logic_hook.php:-

<?php

// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array(); 
$hook_array['before_save']  = Array(1, 'cost', 'custom/modules/aos_products/cost.php', 'cost', 'cost');

?>

and I don’t think you need an individual class and function for each one, you could probably do it all in one function and definitely one class

Hi Matt

Thanks for your reply I have made the changes to the logic_hook file but I am still having no luck. I have also asked my service provider to make the relevant security changes but the hooks are just not working.

I’ve added copies of my files. What I don’t understand is that it works 100% on my Windows 7 machine with wampserver but no luck on the shared host.

Thanks for your help.

Here is my Logic_hook file

$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array[‘before_save’] = Array();
$hook_array[‘before_save’][] = Array(1, ‘cost’, ‘custom/modules/aos_products/cost.php’, ‘cost’, ‘cost’);
$hook_array[‘before_save’][] = Array(2, ‘subtotal’, ‘custom/modules/aos_products/cost.php’, ‘subtotal’, ‘subtotal’);
$hook_array[‘before_save’][] = Array(3, ‘markup’, ‘custom/modules/aos_products/cost.php’, ‘markup’, ‘markup’);
$hook_array[‘before_save’][] = Array(4, ‘selling’, ‘custom/modules/aos_products/cost.php’, ‘selling’, ‘selling’);
$hook_array[‘before_save’][] = Array(5, ‘sqm’, ‘custom/modules/aos_products/cost.php’, ‘sqm’, ‘sqm’);

Here Is the Cost.php

<?php class cost { function cost(&$bean, $event, $arguments) { // calculate item cost $bean->cost = ($bean->cp_lm_c / $bean->width_c); } } class subtotal { function subtotal(&$bean, $event, $arguments) { // calculate item subtotal $bean->subtotcost_c = ($bean->cost + $bean->underfelt_c + $bean->fitters_c); } } class markup { function markup(&$bean, $event, $arguments) { // calculate item markup $bean->markup_c = ($bean->subtotcost_c * $bean->markup_p_c / 100); } } class selling { function selling(&$bean, $event, $arguments) { // calculate item selling $bean->price = ($bean->subtotcost_c + $bean->markup_c + $bean->c_load_c + $bean->lam_fitters_c); } } class sqm { function sqm(&$bean, $event, $arguments) { // calculate item sqm $bean->markup_sqm_c = ($bean->c_load_c + $bean->markup_c); } } ?>

Does anybody have any other suggestions that I could try or changes that I need to put to my hosting service provider


Hi Will

Can somebody please shed some light on the issue as my client loves the product but I need to get the issue resolved below is an insert of my php file

<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array(1, 'cost', 'custom/modules/aos_products/cost.php', 'cost', 'cost'); $hook_array['after_save'][] = Array(2, 'subtotal', 'custom/modules/aos_products/cost.php', 'subtotal', 'subtotal'); $hook_array['after_save'][] = Array(3, 'markup', 'custom/modules/aos_products/cost.php', 'markup', 'markup'); $hook_array['after_save'][] = Array(4, 'selling', 'custom/modules/aos_products/cost.php', 'selling', 'selling'); $hook_array['after_save'][] = Array(5, 'sqm', 'custom/modules/aos_products/cost.php', 'sqm', 'sqm'); $hook_array['after_save'][] = Array(6, 'store', 'custom/modules/aos_products/cost.php', 'store', 'store'); $hook_array['after_save'][] = Array(7, 'storedisc', 'custom/modules/aos_products/cost.php', 'storedisc', 'storedisc'); Where am I going wrong

Check the path of your custom logic file.