[TYPO3-dam-devel] RFC #7762: Failed query during install
Benjamin Mack
benni at typo3.org
Fri May 9 23:56:26 CEST 2008
And commited by Michiel!
Michiel Roos wrote:
> +1
>
> On May 9, 2008, at 10:49 AM, Peter Kuehn [wmdb] wrote:
>
>> Hi yall,
>>
>> this is a SVN patch request.
>>
>> Branches: DAM_1.0 and Trunk (1.1)
>>
>> BT Reference: http://bugs.typo3.org/view.php?id=7762
>>
>> Type: Bugfix / Cleanup
>>
>> Descripton from Mantis:
>> -----------------------
>> When installing the DAM on a 4.2 TYPO3 install, the script
>> dam/class.ext_update.php is called many times, each time the
>> CMD[showExt]=dam query parameter is set. This calls
>> ext_update::access() which itself calls ext_update::perform_update().
>>
>> This last method tries to perform some changes on table tx_dam_mm_ref
>> without first checking whether it exists or not. This of course
>> generates a SQL error. It should be just necessary to add a test
>> before calling:
>>
>> $res = $GLOBALS['TYPO3_DB']->admin_get_fields('tx_dam_mm_ref');
>>
>> line 121
>>
>> This happened on a TYPO3 4.2-beta3 install, with DAM not yet
>> installed. Looking at the code it should happen on a 4.1 install too.
>>
>> Steps to reproduce:
>> -------------------
>> install dam on a newborn typo3-db with no dam tables and php set to
>> display_errors=on
>>
>> Solution:
>> ---------
>> check if tx_dam_mm_ref exists before trying to modify it ;)
>>
>> Notes:
>> ------
>> i added a relation to http://bugs.typo3.org/view.php?id=6843 to the
>> ticket. as discussed on the list earlier, the whole
>> class.ext_update.php should be reworked asap in coop with the core team.
>>
>> pls ack
>> gRTz
>> pekue
>> Index: class.ext_update.php
>> ===================================================================
>> --- class.ext_update.php (revision 9116)
>> +++ class.ext_update.php (working copy)
>> @@ -118,21 +118,24 @@
>>
>> if
>> (t3lib_div::int_from_ver(TYPO3_branch)>=t3lib_div::int_from_ver('4.1')) {
>>
>> - $res =
>> $GLOBALS['TYPO3_DB']->admin_get_fields('tx_dam_mm_ref');
>> - if (isset($res['sorting_foreign'])) {
>> - # for testing only:
>> $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam_mm_ref', '',
>> array('sorting_foreign'=>'0'));
>> - $rows =
>> $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(sorting_foreign)',
>> 'tx_dam_mm_ref', 'sorting_foreign>0');
>> - if ($rows['0']['count(sorting_foreign)']==0) {
>> - $GLOBALS['TYPO3_DB']->admin_query('ALTER TABLE
>> tx_dam_mm_ref DROP sorting_foreign');
>> - unset($res['sorting_foreign']);
>> + $existingTables=$GLOBALS['TYPO3_DB']->admin_get_tables();
>> + if(isset($existingTables['tx_dam_mm_ref'])) {
>> + $res =
>> $GLOBALS['TYPO3_DB']->admin_get_fields('tx_dam_mm_ref');
>> + if (isset($res['sorting_foreign'])) {
>> + # for testing only:
>> $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam_mm_ref', '',
>> array('sorting_foreign'=>'0'));
>> + $rows =
>> $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(sorting_foreign)',
>> 'tx_dam_mm_ref', 'sorting_foreign>0');
>> + if ($rows['0']['count(sorting_foreign)']==0) {
>> + $GLOBALS['TYPO3_DB']->admin_query('ALTER
>> TABLE tx_dam_mm_ref DROP sorting_foreign');
>> + unset($res['sorting_foreign']);
>> + }
>> }
>> +
>> + if (!isset($res['sorting_foreign'])) {
>> + $GLOBALS['TYPO3_DB']->admin_query('ALTER TABLE
>> tx_dam_mm_ref CHANGE sorting sorting_foreign int(11) unsigned DEFAULT
>> 0 NOT NULL');
>> + $GLOBALS['TYPO3_DB']->admin_query('ALTER TABLE
>> tx_dam_mm_ref ADD sorting int(11) unsigned DEFAULT 0 NOT NULL');
>> + $content .= 'Renamed field tx_dam_mm_ref.sorting
>> to sorting_foreign<br />';
>> + }
>> }
>> -
>> - if (!isset($res['sorting_foreign'])) {
>> - $GLOBALS['TYPO3_DB']->admin_query('ALTER TABLE
>> tx_dam_mm_ref CHANGE sorting sorting_foreign int(11) unsigned DEFAULT
>> 0 NOT NULL');
>> - $GLOBALS['TYPO3_DB']->admin_query('ALTER TABLE
>> tx_dam_mm_ref ADD sorting int(11) unsigned DEFAULT 0 NOT NULL');
>> - $content .= 'Renamed field tx_dam_mm_ref.sorting to
>> sorting_foreign<br />';
>> - }
>> }
>>
>> return $content;
>> _______________________________________________
>> Before posting to this list, please have a look to the posting rules
>> on the following websites:
>>
>> http://typo3.org/teams/core/core-mailinglist-rules/
>> http://typo3.org/development/bug-fixing/diff-and-patch/
>> _______________________________________________
>> TYPO3-team-dam mailing list
>> TYPO3-team-dam at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-dam
>
>
> Met vriendelijke groet,
>
> Michiel Roos
>
> Netcreators BV :: creation and innovation
> www.netcreators.com
>
> Interesse in werken bij Netcreators?
> http://www.netcreators.com/bedrijf/vacatures/
>
--
greetings,
benni.
-SDG-
More information about the TYPO3-team-dam
mailing list