[Vtigercrm-developers] Cant restore records from custom modules

lajeesh k lajeeshk at gmail.com
Wed Oct 9 07:11:09 GMT 2019


Hi Roben,

Its a vtiger bug.

The problem is the restore process is a transaction.
you can see transaction starts with $this-db->startTransaction()

until the transaction completes other mysql process cannot see the db
changes

the vtiger_record_model::getInstance method in
handleEmailLookupRestoreEvent function uses $adb instance

$adb instance cannot see that db changes
so vtiger_record_model::getInstance returns the error record deleted

either $this->db or $adb should use for all queries inside a transaction




Regards,
Lajeesh
Freelance developer / entrepreneur



On Tue, Oct 8, 2019 at 11:07 PM Rubén A. Estrada Orozco <rulotec1 at gmail.com>
wrote:

> Thanks Lajeesh,
>
> Do you think that $this->db is not initialized or something when called in
> the case of custom modules? If thats the case, then that's a vtiger bug, I
> guess.
>
> I would like to find a solution without changing vtiger's code. Because I
> cannot control that in many cases.
>
> Saludos
>
> Rubén
>
>
> On Tue, Oct 8, 2019 at 9:11 AM lajeesh k <lajeeshk at gmail.com> wrote:
>
>> Hi
>>
>> In restore function change $this->db->pquery to $adb->pquery
>> I had the same issue and fixed this way
>>
>>
>> Regards,
>> Lajeesh
>> Freelance developer / entrepreneur
>>
>>
>>
>> On Fri, Oct 4, 2019 at 7:29 AM Rubén A. Estrada Orozco <
>> rulotec1 at gmail.com> wrote:
>>
>>> Sending this message a second time, because it seems the first time
>>> failed:
>>>
>>> Hi everyone
>>>
>>> Has anybody noticed that restoring records from custom modules fails? It
>>> fails with modules I created as well as with modules from other 3rd
>>> parties. I spent some hours trying to fix it without success :(
>>>
>>> I get the following error:
>>>
>>> [image: image.png]
>>>
>>> If you try to restore it a second time, it takes a while before the http
>>> response is back:
>>> [image: image.png]
>>>
>>> The error is the following:
>>>
>>> Error restoring records : Query Failed:UPDATE vtiger_crmentity SET
>>> deleted=0,modifiedtime=?,modifiedby=? WHERE crmid = ?::ADODB error Error
>>> restoring records : Query Failed:UPDATE vtiger_crmentity SET
>>> deleted=0,modifiedtime=?,modifiedby=? WHERE crmid = ?::->Lock wait timeout
>>> exceeded; try restarting transaction
>>>
>>> Thats because the first time the the restore function at CRMEntity.php
>>>  executes, it doesn't complete (an exception is thrown when triggering the
>>> afterrestore event):
>>>
>>> [image: image.png]
>>>
>>> So the second time you try to restore the record, the vtiger_crmentity
>>> table is locked because of the startTransaction() call at line 1388 (I
>>> think) and that's why it takes a while.
>>>
>>> It is the following handler that throws the exception the first time you
>>> try to restore the record:   modules/Vtiger/handlers/EmailLookupHandler.php
>>> because it tries to instantiate the record that's being restored at line 84:
>>>
>>> [image: image.png]
>>>
>>> The strange thing is that it doesn't fail in the case of Vtiger native
>>> modules but only with custom modules, which is pretty strange.
>>>
>>> Disabling the above event results in successfully being able to restore
>>> records.
>>>
>>> Any help will be greatly appreciated.
>>>
>>> Saludos
>>>
>>> Rubén
>>>
>>> Saludos
>>>
>>> Rubén
>>> _______________________________________________
>>> http://www.vtiger.com/
>>
>> _______________________________________________
>> http://www.vtiger.com/
>
> _______________________________________________
> http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20191009/f6213218/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 25315 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20191009/f6213218/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 60670 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20191009/f6213218/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 144050 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20191009/f6213218/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 99490 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20191009/f6213218/attachment-0007.png>


More information about the vtigercrm-developers mailing list