View Issue Details

IDProjectCategoryView StatusLast Update
0006034OXID eShop (all versions)4.01. Database handlingpublic2015-02-25 17:52
Reportertaniol Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version4.9.2 / 5.2.2 
Summary0006034: recreate Views of oxartextends in module setup, oxartextends2shop not found
DescriptionAfter Module activation and Setup routine, an error appears:
table oxartextends2shop not found
Steps To ReproduceIn my module setup I add multiple columns to oxartextends:

ALTER TABLE oxartextends ADD SMX_MATERIAL TEXT NOT NULL DEFAULT ''
ALTER TABLE oxartextends ADD SMX_MATERIAL_1 TEXT NOT NULL DEFAULT ''
ALTER TABLE oxartextends ADD SMX_MATERIAL_2 TEXT NOT NULL DEFAULT ''
ALTER TABLE oxartextends ADD SMX_MATERIAL_3 TEXT NOT NULL DEFAULT ''

then I recreate views with

oxRegistry::get('oxDbMetaDataHandler')->updateViews(array('oxartextends'));
Additional InformationError: mysql error: [1146: Table 'db337673_177.oxartextends2shop' doesn't exist] in EXECUTE (CREATE OR REPLACE SQL SECURITY INVOKER VIEW `oxv_oxartextends_1` AS SELECT oxartextends.OXID,oxartextends.OXLONGDESC,oxartextends.OXLONGDESC_1,oxartextends.OXLONGDESC_2,oxartextends.OXLONGDESC_3,oxartextends.OXTAGS,oxartextends.OXTAGS_1,oxartextends.OXTAGS_2,oxartextends.OXTAGS_3,oxartextends.OXTIMESTAMP,oxartextends.SMX_MATERIAL,oxartextends.SMX_MATERIAL_1,oxartextends.SMX_MATERIAL_2,oxartextends.SMX_MATERIAL_3 FROM oxartextends INNER JOIN oxartextends2shop as t2s ON t2s.oxmapobjectid=oxartextends.oxmapid WHERE t2s.oxshopid = 1 , ) with user db337673_177
TagsNo tags attached.
ThemeAzure
BrowserAll
PHP Version5.4
Database Versionany

Activities

taniol

2015-01-29 15:33

reporter   ~0010651

In the shop database there isn't a table like oxartextends2shop.

taniol

2015-02-25 13:26

reporter   ~0010719

same behaviour with oxcountry, maybe other tables, too.


mysql error: [1146: Table 'oxcountry2shop' doesn't exist] in EXECUTE (CREATE OR REPLACE SQL SECURITY INVOKER VIEW `oxv_oxcountry_1` AS SELECT oxcountry.OXID,oxcountry.OXACTIVE,oxcountry.OXTITLE,oxcountry.OXISOALPHA2,oxcountry.OXISOALPHA3,oxcountry.OXUNNUM3,oxcountry.OXVATINPREFIX,oxcountry.OXORDER,oxcountry.OXSHORTDESC,oxcountry.OXLONGDESC,oxcountry.OXTITLE_1,oxcountry.OXTITLE_2,oxcountry.OXTITLE_3,oxcountry.OXSHORTDESC_1,oxcountry.OXSHORTDESC_2,oxcountry.OXSHORTDESC_3,oxcountry.OXLONGDESC_1,oxcountry.OXLONGDESC_2,oxcountry.OXLONGDESC_3,oxcountry.OXVATSTATUS,oxcountry.OXTIMESTAMP,oxcountry.SMX_CURRENCY,oxcountry.SMX_DRITTLAND FROM oxcountry INNER JOIN oxcountry2shop as t2s ON t2s.oxmapobjectid=oxcountry.oxmapid WHERE t2s.oxshopid = 1 , ) with user

martinwegele

2015-02-25 14:57

reporter   ~0010720

I think you misunderstood the purpose of the parameter of oxDbMetaDataHandler::updateViews(). In the PHPDoc comment it says:
* @param array $aTables array of DB table name that can store different data per shop like oxArticle

So if you assign oxartextends or oxcountry to this method it will mark this table as being a multishop-table instead of the ones that are marked by the config param:
$aTables = $aTables ? $aTables : $oConfig->getConfigParam('aMultiShopTables');
$oShop->setMultiShopTables($aTables);

Therefore in oxShop::createViewQuery() the following if statement will be true for $sTable = oxartextends:
if (in_array($sTable, $this->getMultiShopTables()) && $iShopId = $this->getId()) {

and thus the reference to the non-existing table oxartextends2shop will be added:
$sJoinSnippet = " INNER JOIN {$sTable}2shop as {$sMappedTable} ON {$sMappedTable}.oxmapobjectid={$sTable}.oxmapid ";

The same happens for all tables you list in the array $ArrayOfTables that is given to oxDbMetaDataHandler::updateViews($ArrayOfTables) for which there was no assignment table oxwhatever2shop created before.

You were trying to update the views for one table only, right? Such functionality is not available within the shop framework right now. You can only update the views for all tables by using oxDbMetaDataHandler::updateViews() / oxShop::generateViews().

In conclusion I think that this issue is not a bug and can therefore be closed.