简体   繁体   English

TYPO3 8.7.10:“where 子句”中的“未知列 'sys_file_reference.uid_local:type'”在具有文件类型属性的新扩展中

[英]TYPO3 8.7.10: “Unknown column 'sys_file_reference.uid_local:type' in 'where clause'” in a new extension with file type property

everybody!大家!

In a new TYPO3 8.7.10 site, i just created a new extension by using Extension Builder.在一个新的 TYPO3 8.7.10 站点中,我刚刚使用 Extension Builder 创建了一个新扩展。 In that extension, there is a model object ("FurnitureFamily") with a file type property (I called it "symbol").在该扩展中,有一个具有文件类型属性(我称之为“符号”)的模型对象(“FurnitureFamily”)。 My extension also has a plugin which displays a list of all furniture families.我的扩展程序还有一个插件,可以显示所有家具系列的列表。 I created a furniture family and a new page with my plugin.我用我的插件创建了一个家具系列和一个新页面。

A new model object in Extension Builder扩展生成器中的新模型对象

扩展生成器中的新模型对象

/**
 * name
 *
 * @var string
 * @validate NotEmpty
 */
protected $name = '';

/**
 * symbol
 *
 * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
 * @cascade remove
 */
protected $symbol = null;

The problem is that, instead of showing a list with my only record, I get the following error:问题是,我没有显示包含我唯一记录的列表,而是收到以下错误:

Oops, an error occurred!糟糕,发生错误! Code: 20180219055419589a6076代码:20180219055419589a6076

With the help of the fh_debug extension, I can get more information about the error:fh_debug扩展的帮助下,我可以获得有关错误的更多信息:

Oops, an error occurred!糟糕,发生错误! Code: 20180219055419589a6076 Unknown column 'sys_file_reference.uid_local:type' in 'where clause' exception code:1472074485 file:/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php line:393 fh_debug trace: file: /typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php" line:226 function:getObjectDataByQuery file: /typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php" line:126 function:getObjectDataByQuery file: /typo3/sysext/extbase/Classes/Persistence/Generic/QueryResult.php" line:113 function:getObjectDataByQuery file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:567 function:getFirst file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:503 function:mapResultToPropertyValue file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:290 function:mapObjectToClassProperty file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" l代码:20180219055419589a6076 'where 子句'异常代码中的未知列'sys_file_reference.uid_local:type':1472074485 文件:/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3Db3Backend.tracephp Typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php" line:226 function:getObjectDataByQuery file: /typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php" line:126 function:getObjectDataByQuery file: / Typo3/sysext/extbase/Classes/Persistence/Generic/QueryResult.php" line:113 function:getObjectDataByQuery file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:567 function:getFirst file :/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:503 function:mapResultToPropertyValue 文件:/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:290功能:mapObjectToClassProperty 文件:/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" l ine:186 function:thawProperties file: /typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:144 function:mapSingleRow ine:186 function:thawProperties 文件:/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php" line:144 function:mapSingleRow

Curiously, when I remove the property "symbol", The list is shown (only with the property "name").奇怪的是,当我删除属性“符号”时,会显示列表(仅带有属性“名称”)。

Being a new installation, I tried compare my database with the specificacion, but there were no changes to make.作为新安装,我尝试将我的数据库与规范进行比较,但没有进行任何更改。

My question is: How can I correct that error?我的问题是:我该如何纠正该错误?

Thank you.谢谢。

The question is quite old but I still had this issue in TYPO3 version 9 and discovered it it's related to extension-builder which is creating some entries for the field uid_local:type .这个问题很老了,但我在 TYPO3 版本 9 中仍然有这个问题,并发现它与 extension-builder 相关,它正在为uid_local:type字段创建一些条目。
The error-message is just blocking everything because for the field is no type defined.错误消息只是阻止了所有内容,因为该字段没有定义类型。

In this screenshot you can see that a field with that name is defined in the table sys_file_reference :在此屏幕截图中,您可以看到在表sys_file_reference定义了具有该名称的字段: 在此处输入图片说明

Scrolling a long list with table-fields down something like this can be discovered:向下滚动带有表字段的长列表,可以发现如下内容: 在此处输入图片说明

There a definition for config.items can be found which has typical definitions for some items that can be selected.可以找到config.items的定义,其中有一些可以选择的项目的典型定义。 Even there is only one item, the structure is typical for some kind of form-element for selection.即使只有一个项目,这种结构也是典型的某种形式元素供选择。 I can imagine form-elements like a select-dropdown-box, radio-buttons or checkboxes.我可以想象表单元素,如选择下拉框、单选按钮或复选框。 All these elements have this kind of code-structure as definition.所有这些元素都具有这种代码结构作为定义。

So what I did do to remove the error-message is to just define a 'type' for the field:所以我为删除错误消息所做的只是为该字段定义一个“类型”:

$tmp_ttnews_vp_columns['uid_local:type']['config']['type'] = 'select';

On the other hand, the field won't be shown usually, as the table sys_file_reference never follows the extbase-logic and is working different.另一方面,该字段通常不会显示,因为表sys_file_reference从不遵循 extbase-logic 并且工作方式不同。 So it's quite easy and useful to remove some code in the file所以删除文件中的一些代码是非常容易和有用的
your_extension/Configuration/TCA/Overrides/sys_file_reference.php
There is a block with definitions for new or changed fields in that table and most code above or below that list can be removed.该表中有一个包含新字段或已更改字段定义的块,并且可以删除该列表上方或下方的大多数代码。

This is above the column-definitions and can be deleted:这是在列定义之上,可以删除: 在此处输入图片说明

And a block like this below the desired code can be deleted too:也可以删除所需代码下方的类似块: 在此处输入图片说明

The documentation about the type field can be found here , in the chapter in the bottom is also about the combined notation explained, just not with uid_local but with file: file:type .关于type字段的文档可以在这里找到,在底部的章节中也有关于组合符号的解释,只是不是使用 uid_local 而是使用 file: file:type

There are many situations respectively details why it couldn't work, here the known cases, I can extend the list based on comments later:有很多情况分别详细说明了为什么它不能工作,这里是已知的情况,我可以稍后根据评论扩展列表:

  • The default mapping created by extension-builder looks somehow like this: extension-builder 创建的默认映射看起来像这样:

config.tx_extbase {
persistence {
 classes {

   WDB\TtnewsVp\Domain\Model\FileReference {
     mapping {
       tableName = sys_file_reference
       recordType = Tx_TtnewsVp_FileReference
     }
   }

 }
}
}

here the line recordType = Tx_TtnewsVp_FileReference is disturbing and provoking the error-message like described in the question.这里的行recordType = Tx_TtnewsVp_FileReference令人不安并引发问题中描述的错误消息。
This kind of TypoScript is usually in the file ext_typoscript_setup.typoscript in the root of the extension-folder, so it's always loaded, even if the static template is not included.这种 TypoScript 通常在扩展文件夹根目录下的文件ext_typoscript_setup.typoscript中,因此它总是被加载,即使不包含静态模板。

  • Annotations in classes might be wrong, including simple faults like typos.类中的注释可能是错误的,包括像拼写错误这样的简单错误。 Annotations and type-hinting have to be correct (perhaps a missing one is better than a wrong one, but I never tried with missing annotations or type-hints).注释和类型提示必须是正确的(也许缺少的比错误的好,但我从未尝试过缺少注释或类型提示)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM