{"action":"created","issue":{"url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/902","repository_url":"https://api.github.com/repos/salesagility/SuiteCRM","labels_url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/902/labels{/name}","comments_url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/902/comments","events_url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/902/events","html_url":"https://github.com/salesagility/SuiteCRM/issues/902","id":129823764,"number":902,"title":"new SugarBean per se resets custom_fields on Callvardefs.php","user":{"login":"adriangibanelbtactic","id":1331363,"avatar_url":"https://avatars.githubusercontent.com/u/1331363?v=3","gravatar_id":"","url":"https://api.github.com/users/adriangibanelbtactic","html_url":"https://github.com/adriangibanelbtactic","followers_url":"https://api.github.com/users/adriangibanelbtactic/followers","following_url":"https://api.github.com/users/adriangibanelbtactic/following{/other_user}","gists_url":"https://api.github.com/users/adriangibanelbtactic/gists{/gist_id}","starred_url":"https://api.github.com/users/adriangibanelbtactic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adriangibanelbtactic/subscriptions","organizations_url":"https://api.github.com/users/adriangibanelbtactic/orgs","repos_url":"https://api.github.com/users/adriangibanelbtactic/repos","events_url":"https://api.github.com/users/adriangibanelbtactic/events{/privacy}","received_events_url":"https://api.github.com/users/adriangibanelbtactic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-29T16:59:22Z","updated_at":"2016-03-14T15:09:38Z","closed_at":"2016-03-14T15:09:38Z","body":"Read first\r\n========\r\nSo, please read: #901 . This is a continuation. This means this bug happens in tag: v4.7 exactly. I'm not sure it can be triggered in a clean v4.7 installation but it happens to our installation.\r\n\r\nWhat happens\r\n===========\r\nSo basically when visit: Meetings (List View) the file:\r\ncache/modules/Calls/Callvardefs.php\r\n(and, actually many of the other files)\r\nlose the:\r\ncustom_fields definition.\r\n\r\nOnce that happens when you go to: Calls the first search is doomed to fail and the logs show something similar to:\r\n\r\n```\r\nThu Jan 28 18:36:14 2016 [7062][1][FATAL]  Query Failed:  SELECT  calls.id , calls.parent_id , calls.assigned_user_id , calls.recurring_source , calls.status , calls.direction , calls.name , calls.contact_c  , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) contact_name, jtl0.contact_id contact_id, calls.parent_type , calls.date_start  , jt1.user_name assigned_user_name , jt1.created_by assigned_user_name_owner  , 'Users' assigned_user_name_mod, calls.date_entered , calls.created_by  FROM calls   LEFT JOIN  calls_contacts jtl0 ON calls.id=jtl0.call_id AND jtl0.deleted=0\r\n\r\n LEFT JOIN  contacts contacts ON contacts.id=jtl0.contact_id AND contacts.deleted=0\r\n AND contacts.deleted=0  LEFT JOIN  users jt1 ON calls.assigned_user_id=jt1.id AND jt1.deleted=0\r\n\r\n AND jt1.deleted=0 where calls.deleted=0 ORDER BY calls.direction ASC LIMIT 0,101: MySQL error 1054: Unknown column 'calls.contact_c' in 'field list'\r\n```\r\nwhere: contact_c is a Calls' custom field.\r\n\r\nDigging into the code\r\n================\r\n\r\nSo, now I continue my #901 explanation. So, when you visit Meetings (List View) somehow it uses getListViewData function from ListViewData.php.\r\n\r\nhttps://github.com/salesagility/SuiteCRM/blob/b533ad20e5cf0a51dcd35cb99b9c2f97eabd86bc/include/ListView/ListViewData.php#L232\r\n\r\nwhich in turn calls: getTotalCount either here:\r\nhttps://github.com/salesagility/SuiteCRM/blob/b533ad20e5cf0a51dcd35cb99b9c2f97eabd86bc/include/ListView/ListViewData.php#L317\r\nor here:\r\nhttps://github.com/salesagility/SuiteCRM/blob/b533ad20e5cf0a51dcd35cb99b9c2f97eabd86bc/include/ListView/ListViewData.php#L464\r\n\r\n.\r\n\r\nThat's where we get into:\r\n\r\nhttps://github.com/salesagility/SuiteCRM/blob/b533ad20e5cf0a51dcd35cb99b9c2f97eabd86bc/include/ListView/ListViewData.php#L187\r\n\r\nwhich it's fixed on master branch.\r\n\r\nBut if you are using: v7.4 tag you get:\r\n\r\nhttps://github.com/salesagility/SuiteCRM/blob/v7.4/include/ListView/ListViewData.php#L187-L188\r\n\r\n```\r\n            $objSugarBean = new SugarBean();\r\n\t        $count_query = $objSugarBean->create_list_count_query($main_query);\r\n```\r\n\r\nso, once again, taking a look at: #901 for intermediate debug steps we are finally in:\r\n\r\nhttps://github.com/salesagility/SuiteCRM/blob/5e73e57778bacc7cf88d99f15c409210244dd387/modules/DynamicFields/DynamicField.php#L149\r\n\r\nsaveToVardef is called.\r\n\r\nIf you debug it further you will see that it will somehow resave the:\r\n```\r\ncache/modules/Calls/Callvardefs.php\r\n```\r\nfile without taking into account the:\r\n```\r\ncustom_fields\r\n```\r\nvalue.\r\n\r\nAnd  then when going into Calls, well, I guess it assumes the Callvardefs.php it's correct, it loads it, and it lacks custom_fields. So... you get the mysql error.\r\n\r\nI'm bringing this error here because although as I said in #901 it only happens in v7.4 tag this other part of the code which continues to work with $module being empty is here on master branch ( Current commit: d7f628911d4165a8033bdf14cb51cceff3977f05 ).\r\n\r\nAnd in this case it has unattended consequences.\r\n\r\nAs I said maybe there's something going around that only affects our installation that I'm unaware of.\r\n\r\nBut, currently, this makes going to Meetings ... to fail any other module that has custom fields. Only once but it happens.\r\n\r\nSo...\r\n\r\n* Going into Meetings. Going into Calls. The search fails.\r\n* Going into Meetings. Someone else is in Accounts trying to create a Contact from subpanel... it fails.\r\n\r\nAll of these actions fail because of this problem."},"comment":{"url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/comments/196359933","html_url":"https://github.com/salesagility/SuiteCRM/issues/902#issuecomment-196359933","issue_url":"https://api.github.com/repos/salesagility/SuiteCRM/issues/902","id":196359933,"user":{"login":"mattlorimer","id":6449723,"avatar_url":"https://avatars.githubusercontent.com/u/6449723?v=3","gravatar_id":"","url":"https://api.github.com/users/mattlorimer","html_url":"https://github.com/mattlorimer","followers_url":"https://api.github.com/users/mattlorimer/followers","following_url":"https://api.github.com/users/mattlorimer/following{/other_user}","gists_url":"https://api.github.com/users/mattlorimer/gists{/gist_id}","starred_url":"https://api.github.com/users/mattlorimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattlorimer/subscriptions","organizations_url":"https://api.github.com/users/mattlorimer/orgs","repos_url":"https://api.github.com/users/mattlorimer/repos","events_url":"https://api.github.com/users/mattlorimer/events{/privacy}","received_events_url":"https://api.github.com/users/mattlorimer/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T15:09:38Z","updated_at":"2016-03-14T15:09:38Z","body":"fixed in 7.5"}}