Crossposting this issue: #1087898: PDOException: SQLSTATE[HY000] on batch export
If my view contains a column that is defined by Views PHP, this columns is not exported by 'Views Data Export'.
My guess is that some Views callback is missing.

Comments

hadsie’s picture

Category:feature» bug

I'm getting this same error. You have any luck figuring out a work around? It looks like I'm just going to have to write a custom views field for my solution.

johnv’s picture

Status:Needs review» Active

No, and even worse: my current VDE-exports only export node-titles :-( .
I don't know yet if this is due to a update of VDE of an update of Views.

johnv’s picture

Status:Active» Fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gabrielu’s picture

Status:Closed (fixed)» Active

How can this be related to table character encoding. All my tables are UTF8 but the PHP is never called there.
So the problem is about integrating Views PHP with Views Data Export. In the preview of VDE I see the result of my PHP FIeld, but not in the file, the file is always blank.

pineray’s picture

I ran into the same trouble.
However, I applied the following modifications and it worked correctly.

Change the function name php_post_execute() in views_php_handler_field.inc to post_execute() and php_pre_execute() to pre_execute().

johnv’s picture

BWPanda’s picture

Status:Active» Needs review
StatusFileSize
new1020 bytes

PineRay's solution worked for me, though I don't really understand it...

I've attached a patch that should be tested to make sure it doesn't break anything.

Amarjit’s picture

Status:Active» Needs review
StatusFileSize
new1.09 KB

The patch actually worked for me but with an error.

Strict warning: Declaration of views_php_handler_field::post_execute() should be compatible with that of views_handler::post_execute() in _registry_check_code() (line 2982 of \includes\bootstrap.inc).

I did some scavenging around on the function 'post_execute'. It seems this function needs the reference for $variables to be passed in. Even though this is not used, it's part of the function prototype.

See here »

Amarjit.

meghanmary’s picture

@Amarjit - This patch worked for me - thanks so much!

drewish’s picture

Status:Needs review» Reviewed & tested by the community

Worked well for us too.

ttkaminski’s picture

A quick grep on the source files shows this:

plugins/views/views_php_handler_field.inc:   * @see self::php_post_execute()
plugins/views/views_php_handler_field.inc:   * @see self::php_post_execute()
plugins/views/views_php_handler_field.inc:  function php_pre_execute() {
plugins/views/views_php_handler_field.inc:  function php_post_execute() {
plugins/views/views_php_plugin_pager.inc:        if (is_callable(array($handler, 'php_pre_execute'))) {
plugins/views/views_php_plugin_pager.inc:          $handler->php_pre_execute();
plugins/views/views_php_plugin_pager.inc:        if (is_callable(array($handler, 'php_post_execute'))) {
plugins/views/views_php_plugin_pager.inc:          $handler->php_post_execute();
plugins/views/views_php_handler_sort.inc:  function php_pre_execute() {
plugins/views/views_php_handler_sort.inc:  function php_post_execute() {
plugins/views/views_php_handler_filter.inc:  function php_pre_execute() {
plugins/views/views_php_handler_filter.inc:  function php_post_execute() {

Should these files be updated as well?

junedkazi’s picture

Status:Reviewed & tested by the community» Needs work
+++ b/docroot/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc
@@ -111,7 +111,7 @@ class views_php_handler_field extends views_handler_field {
-  function php_pre_execute() {

You cannot change the function name. As it is being called from the views_php_plugin_pager.inc file.

+++ b/docroot/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc
@@ -125,14 +125,14 @@ class views_php_handler_field extends views_handler_field {
-  function php_post_execute() {

You cannot change the function name. As it is being called from the views_php_plugin_pager.inc file.

johnv’s picture

@junedkazi , the function names have been changed similarly in other patches, too. With succes.
It seems like Views PHP has a lot of D6-code, which is not working anymore. This might be a D6-D7 api change.

junedkazi’s picture

@johnv I do understand that it is not working and a change is necessary. But by comment was regards to the patch in comment 9 where it is changed for only one file instead of the complete module. Hence the comment you cannot change it at one place as it makes the whole code much more vulnerable if someone applies this patch.

vensires’s picture

I have to offer another idea - based of course on #6. In views_php_handler_field.inc Instead of fixing the function names and the callers, I only added the following functions to the views_php_handler_field class:

<?php
function pre_execute() {
 
$this->php_pre_execute();
}
function
post_execute() {
 
$this->php_post_execute();
}
?>
fiftyz’s picture

Issue summary:View changes
Status:Needs work» Needs review
StatusFileSize
new543 bytes

The solution from #16 is working fine and I also think is good for compatibility so here is a patch for this.

A better approach is to move content of php_pre_execute() and php_post_exectue() to pre_execute() and post_execute() and php_pre|post_execute() to return the output of pre|post_execute for views API consistency.

fiftyz’s picture

Title:Views PHP columns are not supported by Views Data Export» Views PHP pre and post execute extender implementation
DevDaveUK’s picture

Patch #17 works for me - the views php columns are now populated in the exported CSV, however, I have the following error on the page with my view:

Strict warning: Declaration of views_php_handler_field::post_execute() should be compatible with that of views_handler::post_execute() in _registry_check_code() (line 3139 of /Users/davidlong/Sites/devdesktop/registers/includes/bootstrap.inc).
fiftyz’s picture

@DevDaveUK please post you view (exported). I'm using this patch for 4 months now on production and I don't receive that error.

By the way, did you cleared cache and views cache after applying the #17 patch? You should do that and post your feedback afterwards pls.

DevDaveUK’s picture

<?php
$empty
= "a course";
$course = array(
"VGD"=>"Video Game Development",
"ANI2D"=>"Stop Motion and 2D Animation",
"DMJR"=>"Digital Music Production for 10-12 year olds",
"DMSR"=>"Digital Music Production for 13+ year olds",
"TCJ"=>"Java with Greenfoot",
"TCP"=>"Teen Python"
);

$course_abr = $row->name;
if (
array_key_exists($course_abr, $course)) {
return
$course[$course_abr];
} else {
return
$empty;
}

$directions = "Test";
If (
$row->name_1 == "London" && $row->name != "RAP") {
$directions = "Message text goes here.";
} else if (
$row->name_1 == "London" && $row->name == "RAP") {
$directions = "TMessage text goes here";
} else if (
$row->name_1 == "Manchester") {
$directions = "Message text goes here.";
} else if (
$row->name_1 == "Bristol") {
$directions = "Message text goes here.";
} else if (
$row->name_1 == "Brighton") {
$directions = "Message text goes here.";
}
return
$directions;
-----

$view = new view();
$view->name = 'emails';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Emails';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */

$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Welcome Emails';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'table';
/* Relationship: Parent */
$handler->display->display_options['relationships']['field_nr_parent_nid']['id'] = 'field_nr_parent_nid';
$handler->display->display_options['relationships']['field_nr_parent_nid']['table'] = 'field_data_field_nr_parent';
$handler->display->display_options['relationships']['field_nr_parent_nid']['field'] = 'field_nr_parent_nid';
$handler->display->display_options['relationships']['field_nr_parent_nid']['ui_name'] = 'Parent';
$handler->display->display_options['relationships']['field_nr_parent_nid']['delta'] = '-1';
/* Relationship: Child */
$handler->display->display_options['relationships']['field_child_nid']['id'] = 'field_child_nid';
$handler->display->display_options['relationships']['field_child_nid']['table'] = 'field_data_field_child';
$handler->display->display_options['relationships']['field_child_nid']['field'] = 'field_child_nid';
$handler->display->display_options['relationships']['field_child_nid']['ui_name'] = 'Child';
$handler->display->display_options['relationships']['field_child_nid']['delta'] = '-1';
/* Relationship: Courses */
$handler->display->display_options['relationships']['term_node_tid']['id'] = 'term_node_tid';
$handler->display->display_options['relationships']['term_node_tid']['table'] = 'node';
$handler->display->display_options['relationships']['term_node_tid']['field'] = 'term_node_tid';
$handler->display->display_options['relationships']['term_node_tid']['ui_name'] = 'Courses';
$handler->display->display_options['relationships']['term_node_tid']['label'] = 'terms_course';
$handler->display->display_options['relationships']['term_node_tid']['vocabularies'] = array(
 
'course' => 'course',
 
'camp' => 0,
 
'course_type' => 0,
 
'location' => 0,
 
'school' => 0,
 
'tags' => 0,
 
'tutor' => 0,
);
/* Relationship: Locations */
$handler->display->display_options['relationships']['term_node_tid_1']['id'] = 'term_node_tid_1';
$handler->display->display_options['relationships']['term_node_tid_1']['table'] = 'node';
$handler->display->display_options['relationships']['term_node_tid_1']['field'] = 'term_node_tid';
$handler->display->display_options['relationships']['term_node_tid_1']['ui_name'] = 'Locations';
$handler->display->display_options['relationships']['term_node_tid_1']['label'] = 'term_location';
$handler->display->display_options['relationships']['term_node_tid_1']['vocabularies'] = array(
 
'location' => 'location',
 
'camp' => 0,
 
'course' => 0,
 
'course_type' => 0,
 
'school' => 0,
 
'tags' => 0,
 
'tutor' => 0,
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title_1']['id'] = 'title_1';
$handler->display->display_options['fields']['title_1']['table'] = 'node';
$handler->display->display_options['fields']['title_1']['field'] = 'title';
$handler->display->display_options['fields']['title_1']['relationship'] = 'field_nr_parent_nid';
$handler->display->display_options['fields']['title_1']['link_to_node'] = FALSE;
/* Field: Content: Parent Name */
$handler->display->display_options['fields']['field_parent_name']['id'] = 'field_parent_name';
$handler->display->display_options['fields']['field_parent_name']['table'] = 'field_data_field_parent_name';
$handler->display->display_options['fields']['field_parent_name']['field'] = 'field_parent_name';
$handler->display->display_options['fields']['field_parent_name']['relationship'] = 'field_nr_parent_nid';
$handler->display->display_options['fields']['field_parent_name']['type'] = 'text_plain';
/* Field: Content: Child Name */
$handler->display->display_options['fields']['field_child_name']['id'] = 'field_child_name';
$handler->display->display_options['fields']['field_child_name']['table'] = 'field_data_field_child_name';
$handler->display->display_options['fields']['field_child_name']['field'] = 'field_child_name';
$handler->display->display_options['fields']['field_child_name']['relationship'] = 'field_child_nid';
$handler->display->display_options['fields']['field_child_name']['type'] = 'text_plain';
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'term_node_tid';
$handler->display->display_options['fields']['name']['label'] = 'Course';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_4']['id'] = 'php_4';
$handler->display->display_options['fields']['php_4']['table'] = 'views';
$handler->display->display_options['fields']['php_4']['field'] = 'php';
$handler->display->display_options['fields']['php_4']['label'] = 'Course Name';
$handler->display->display_options['fields']['php_4']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_4']['php_value'] = '$empty = "a course";
$course = array(
"VGD"=>"Video Game Design",
"ANI2D"=>"Stop Motion and 2D Animation",
"T3D"=>"Teen 3D Animation",
"DMJR"=>"Digital Music Production",
"DMSR"=>"Digital Music Production",
"TCJ"=>"Coding Java with Greenfoot",
"TCP"=>"Teen Coding with Python",
"ROB"=>"Robotics with LEGO Mindstorms",
"THC"=>"Physical Computing with Arduino",
"RAP" =>"Rapid Prototyping: An Introduction to Making"
);

$course_abr = $row->name;
if (array_key_exists($course_abr, $course)) {
return $course[$course_abr];
} else {
return $empty;
}'

;
$handler->display->display_options['fields']['php_4']['php_output'] = '<?php echo $value; ?>
';
$handler->display->display_options['fields']['php_4']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_4']['php_click_sortable'] = '';
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['relationship'] = 'term_node_tid_1';
$handler->display->display_options['fields']['name_1']['label'] = 'Location';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_5']['id'] = 'php_5';
$handler->display->display_options['fields']['php_5']['table'] = 'views';
$handler->display->display_options['fields']['php_5']['field'] = 'php';
$handler->display->display_options['fields']['php_5']['label'] = 'Location Text';
$handler->display->display_options['fields']['php_5']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_5']['php_value'] = '$locationName = "default address goes here";
If ($row->name_1 == "London" && $row->name != "RAP") {
//Imperial
$locationName = "address goes here";
} else if ($row->name_1 == "London" && $row->name == "RAP") {
//Makerversity
$locationName = "address goes here";
} else if ($row->name_1 == "Manchester") {
$locationName = "address goes here";
} else if ($row->name_1 == "Bristol") {
$locationName = "address goes here";
} else if ($row->name_1 == "Brighton") {
$locationName = "address goes here";
}
return $locationName;';
$handler->display->display_options['fields']['php_5']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_5']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_5']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php']['id'] = 'php';
$handler->display->display_options['fields']['php']['table'] = 'views';
$handler->display->display_options['fields']['php']['field'] = 'php';
$handler->display->display_options['fields']['php']['label'] = 'Map';
$handler->display->display_options['fields']['php']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php']['php_value'] = 'if($row->name_1 == "London" && $row->name !="RAP"){
$mapImageUrl = "/images/imperial-map.jpg";
} else if($row->name_1 == "London" && $row->name =="RAP"){
$mapImageUrl = "/images/makerversity-map.jpg";
} else if($row->name_1 == "Manchester") {
$mapImageUrl = "/images/mosi-map.jpg";
} else if($row->name_1 == "Bristol") {
$mapImageUrl = "/images/uwe-map.jpg";
} else if($row->name_1 == "Brighton") {
$mapImageUrl = "/images/falmer-map.jpg";
} else {
$mapImageUrl = "";
}
return $mapImageUrl;';
$handler->display->display_options['fields']['php']['php_output'] = 'url goes here/<?php echo $value; ?>';
$handler->display->display_options['fields']['php']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_1']['id'] = 'php_1';
$handler->display->display_options['fields']['php_1']['table'] = 'views';
$handler->display->display_options['fields']['php_1']['field'] = 'php';
$handler->display->display_options['fields']['php_1']['label'] = 'Course Time';
$handler->display->display_options['fields']['php_1']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_1']['php_value'] = '$cTime = "All day";
If($row->name_1 == "London" && $row->name == "VGD" || $row->name == "ROB" || $row->name == "RAP" || $row->name == "ANI2D" || $row->name == "DMJR" || $row->name_1 == "London" && $row->name == "MIN") {
$cTime = "9am-5pm";
} else {
$cTime = "10am-3pm";
}
return $cTime;';
$handler->display->display_options['fields']['php_1']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_1']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_1']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_2']['id'] = 'php_2';
$handler->display->display_options['fields']['php_2']['table'] = 'views';
$handler->display->display_options['fields']['php_2']['field'] = 'php';
$handler->display->display_options['fields']['php_2']['label'] = 'Drop Off';
$handler->display->display_options['fields']['php_2']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_2']['php_value'] = '$cTime = "All day";
If($row->name_1 == "London" && $row->name == "VGD" || $row->name == "ROB" || $row->name == "RAP" || $row->name == "ANI2D" || $row->name == "DMJR" || $row->name_1 == "London" && $row->name == "MIN") {
$cTime = "8:45am";
} else {
$cTime = "9:45am";
}
return $cTime;';
$handler->display->display_options['fields']['php_2']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_2']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_2']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_3']['id'] = 'php_3';
$handler->display->display_options['fields']['php_3']['table'] = 'views';
$handler->display->display_options['fields']['php_3']['field'] = 'php';
$handler->display->display_options['fields']['php_3']['label'] = 'What to bring';
$handler->display->display_options['fields']['php_3']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_3']['php_value'] = '$materials = "message text goes here.";
If($row->name == "TCJ" || $row->name == "TCP") {
$materials = "message text goes here";
} else if ($row->name == "MIN") {
$materials = "message text goes here.";
}
return $materials;';
$handler->display->display_options['fields']['php_3']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_3']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_3']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_6']['id'] = 'php_6';
$handler->display->display_options['fields']['php_6']['table'] = 'views';
$handler->display->display_options['fields']['php_6']['field'] = 'php';
$handler->display->display_options['fields']['php_6']['label'] = 'Directions';
$handler->display->display_options['fields']['php_6']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_6']['php_value'] = '$directions = "";
If ($row->name_1 == "London" && $row->name != "RAP") {
$directions = "message text goes here.";
} else if ($row->name_1 == "London" && $row->name == "RAP") {
$directions = "message text goes here";
} else if ($row->name_1 == "Manchester") {
$directions = "message text goes here.";
} else if ($row->name_1 == "Bristol") {
$directions = "message text goes here.";
} else if ($row->name_1 == "Brighton") {
$directions = "message text goes here.";
}
return $directions;';
$handler->display->display_options['fields']['php_6']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_6']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_6']['php_click_sortable'] = '';
/* Field: Global: PHP */
$handler->display->display_options['fields']['php_7']['id'] = 'php_7';
$handler->display->display_options['fields']['php_7']['table'] = 'views';
$handler->display->display_options['fields']['php_7']['field'] = 'php';
$handler->display->display_options['fields']['php_7']['label'] = 'Extended Care';
$handler->display->display_options['fields']['php_7']['use_php_setup'] = 0;
$handler->display->display_options['fields']['php_7']['php_value'] = 'If($row->name_1 != "London"){
$exc = "message text goes here";
} else {
$exc = "";
}
return $exc';
$handler->display->display_options['fields']['php_7']['php_output'] = '<?php echo $value; ?>';
$handler->display->display_options['fields']['php_7']['use_php_click_sortable'] = '0';
$handler->display->display_options['fields']['php_7']['php_click_sortable'] = '';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'order' => 'order',
);

/* Display: Welcome */
$handler = $view->new_display('page', 'Welcome', 'page');
$handler->display->display_options['display_description'] = 'Welcome Emails';
$handler->display->display_options['path'] = 'welcome-emails';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Emails';
$handler->display->display_options['menu']['name'] = 'features';

/* Display: Data export */
$handler = $view->new_display('views_data_export', 'Data export', 'views_data_export_1');
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'views_data_export_csv';
$handler->display->display_options['style_options']['provide_file'] = 1;
$handler->display->display_options['style_options']['filename'] = '%view_%timestamp-full.csv';
$handler->display->display_options['style_options']['parent_sort'] = 0;
$handler->display->display_options['style_options']['quote'] = 1;
$handler->display->display_options['style_options']['trim'] = 0;
$handler->display->display_options['style_options']['replace_newlines'] = 0;
$handler->display->display_options['style_options']['header'] = 1;
$handler->display->display_options['style_options']['keep_html'] = 0;
$handler->display->display_options['path'] = 'welcome-email-csv';
$handler->display->display_options['displays'] = array(
  'page' => 'page',
  'default' => 0,
);
$handler->display->display_options['use_batch'] = 'batch';
$handler->display->display_options['segment_size'] = '400';

?>

SocialNicheGuru’s picture

need to provide a patch but the fix in views_php_handler_field.inc at about line 119 is

// add &$values needed for post_execute not pre_execute
  function post_execute(&$values) {
    return $this->php_post_execute();
  }

There are several post_execute functions in views. I went with the definition in the views field handler:
modules/field/views_handler_field_field.inc:628: function post_execute(&$values) {

I did not find a specific views handler pre_execute function so I guess the one defined in views.inc should work just fine. Thus no error for that function.

Anybody’s picture

StatusFileSize
new551 bytes

The patch from #17 looks nearly fine.

One thing was just that

<?php
function post_execute(&$values) {
    return
$this->php_post_execute();
}
?>

was missing the $values parameter, which lead to the problem described in #19. This is now fixed with the patch attached.

The question is, if pre_execute is required anyway. What's the reason for that? Is that ever being called?
views_field_handler does not contain such a function. See https://api.drupal.org/api/views/handlers!views_handler_field.inc/class/...

I've tested the export with the patch and it works great :)

Let's finish this!

rcodina’s picture

I have the problem described here and patch on #23 don't work for me.

zmove’s picture

Status:Needs review» Reviewed & tested by the community

patch #17 perfectly works