Project

General

Profile

Actions

Bug #17043

closed

Hook processDatamap_afterDatabaseOperations bug with inline relations?

Added by Stefano Cecere over 17 years ago. Updated over 16 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2007-02-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

i am using the hook processDatamap_afterDatabaseOperations to process a field in a custom table, where i have an inline relation with another table.

the value of this calculated field is based on the NUMBER of linked (by inline relations) records.

the problem is this:

whenever i add or remove an inline relationed record, and save the form, my calculated field is wrong: my function (which counts the linked records with a simple query) gets the PREVIUOS count of linkied records...

it seems that the inline relationschip db updates happen AFTER the hook is called...
the proof is that if i RE-SAVE the form, the field gets a correct value.

i looked into class.t3lib_tcemain.php and i think that the problem is in the loop around all the tables to be updated... i think that the main table gets updated first... so it call my hook/function.. then it updated the inline relationed table

any comment/ideas?

(issue imported from #M5074)


Files

0005074.patch (4.89 KB) 0005074.patch Administrator Admin, 2007-03-01 13:44
class.t3lib_tcemain.php.r2182.zip (64.3 KB) class.t3lib_tcemain.php.r2182.zip Administrator Admin, 2007-03-08 18:03
0005074_v2.patch (9.68 KB) 0005074_v2.patch Administrator Admin, 2007-05-03 14:40

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Feature #17264: Hook in TCEmain after all database operations neededClosedOliver Hader2007-04-29

Actions
Related to TYPO3 Core - Bug #17772: Hook processDatamap_afterDatabaseOperations bug with inline relationsClosedOliver Hader2007-11-10

Actions
Actions #1

Updated by Oliver Hader over 17 years ago

Hi Stefano, could you please attach your extension or a reduced test extension to find the bug faster? Thanks in advance.

Actions #2

Updated by Oliver Hader over 17 years ago

The attached file 0005074.patch should solve this issue for the mentioned hook. In future it could be necessary also to consider the processDatamap_postProcessFieldArray hook - but this could lead to some problems.
For the moment, I just took care of the processDatamap_afterDatabaseOperations hook.
I didn't test it, so please tell me if it works.

Actions #3

Updated by Stefano Cecere over 17 years ago

Ciao Oliver

i did try your patch (on RC2).. but it 1) doesn't work 2) inline creation of new records doesn't work anymore...

maybe i did some errors applying the diff?

could you please attach here the whole new class.t3lib_tcemain.php so i can test it better?

thanks
stefano

Actions #4

Updated by Pardon Niels over 17 years ago

Hello Oliver,

I discovered the same problem. I applied you're patch and the problem is solved for me.

Greets,

Niels

Actions #5

Updated by Oliver Hader over 17 years ago

The patch file I attached was untested. But now I tested it and had no problems at all. Please consider that fieldArray is only filled if the value to be written to the database changed.
@Stefano Cecere: I'm going to add the whole class.t3lib_tcemain.php so you can test easily.

Actions #6

Updated by Stefano Cecere over 17 years ago

thanks Oliver

now it works well when i ADD new inline records.

but if i delete them, i have to save twice to have the hooked function calculate well the number of linked records.

Actions #7

Updated by Oliver Hader over 17 years ago

Sorry, I cannot reproduce this on removing child records. I've tested direct relations (1:n) with comma-separated-list and foreign_field and with the disposal of an intermediate table (m:n). You can send me your extension/configuration directly via e-mail to "oh [at] inpublica [dot] de" and I'll have a closer look at it.

Actions #8

Updated by Oliver Hader over 17 years ago

Stefano, did you experience further errors of the hook? I've sent you a patch for your extension some days ago via e-mail...

Actions #9

Updated by Oliver Hader over 17 years ago

Any news on this? Did someone experience further problems using the patch? If nobody objects I'm going to publish this on the Core-List.

Actions #10

Updated by Stefano Cecere over 17 years ago

hi Oliver

yes, now it works (with your little modification to my ext)

as i wrote in the email, we shoudl explain that an INSERT new (inline) records is a bit "slower" than an UPDATE query

so the COUNT of the inline records can't be done with a simple SELECT, but should be done using the code:

$count = $fieldArray['objects_to_count'];

right?

ciao

Actions #11

Updated by Stefano Cecere over 17 years ago

ops.. sorry

i made some deeper tests, and it doesn't work perfectly...
tomorrow i'll do better tests

Actions #12

Updated by Niels Pardon over 17 years ago

Last update was over a month ago. When will the patch be included in the core? Would be nice if the next release of TYPO3 4.1 includes this patch!

Actions #13

Updated by Oliver Hader over 17 years ago

The patch was published on the Core-List as RFC and needs approval by other Core-Devs. But I think it will be available in TYPO3 4.1.2

Actions #14

Updated by Oliver Hader over 17 years ago

Committed to SVN (TYPO3_4-1 and Trunk)

Actions

Also available in: Atom PDF