Download & Extend

Bugfix and improvements for custom function

Project:Views Calc
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

As pointed out in http://drupal.org/node/552310 documentation for "custom function" was lacking, so i had to dive into the code to figure it out.

I found a bug: in line 86 of views_calc_field_handler.inc, it checks "if ($function == 'custom')", but $function here will contain '' in case of custom function. It should check "if ($this->definition['format'] == 'custom')".

I found also a limit in custom definition: it uses the format "function_name:param", and you can use only a custom parameter. I extended it to allow usage of the format "function_name:param1:param2:...", converted in "function_name($value,param1,param2,...)".

However I think this is yet a strong limitation, so I added the format "php" that allows to define custom php code using $value to get and update field value.

Now the limitation is that the "custom" field is stored in the database as a varchar(255), and may be better to upgrade it to a "text" field.

The attached patch works form me with the last stable version (6.x-1.3)

AttachmentSize
views_calc-custom_php.patch3.29 KB

Comments

#1

Hi,

After a year, I see no progress...

I update the patch, so now this is against head.

I hope in a new release soon.

AttachmentSize
views_calc-head-20101018-custom_php.patch 3.29 KB

#2

Status:needs review» needs work

I'm open to improve this.

However i'd like to contain in the commit also the clean field change/upgrade.
Also i'd love to see the code more documented. (Please follow doc standard!)

Could you please reroll and upgrade.