Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data Object] Relations should be always lazy loaded, remove config o… #5775

Merged
merged 12 commits into from Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -559,11 +559,7 @@ private function getDataForField($object, $key, $fielddefinition, $objectFromVer
// ReverseManyToManyObjectRelation should go in there anyway (regardless if it a version or not),
// so that the values can be loaded.
if (
(
!$objectFromVersion
&& $fielddefinition instanceof AbstractRelations
&& $fielddefinition->getLazyLoading()
)
(!$objectFromVersion && $fielddefinition instanceof AbstractRelations)
|| $fielddefinition instanceof ReverseManyToManyObjectRelation
) {
$refId = null;
Expand Down
Expand Up @@ -32,10 +32,6 @@ pimcore.object.classes.data.advancedManyToManyObjectRelation = Class.create(pimc

this.initData(initData);

if (typeof this.datax.lazyLoading == "undefined") {
this.datax.lazyLoading = true;
}

// overwrite default settings
this.availableSettingsFields = ["name","title","tooltip","mandatory","noteditable","invisible",
"visibleGridView","visibleSearch","style"];
Expand Down Expand Up @@ -82,27 +78,6 @@ pimcore.object.classes.data.advancedManyToManyObjectRelation = Class.create(pimc
disabled: this.isInCustomLayoutEditor(),
minValue: 0
},
{
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible(),
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible()
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_description'),
cls: "pimcore_extra_label_bottom",
style: "padding-bottom:0;"
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_warning_block'),
cls: "pimcore_extra_label_bottom",
style: "color:red; font-weight: bold;"
},
{
xtype: 'textfield',
width: 600,
Expand Down Expand Up @@ -401,7 +376,6 @@ pimcore.object.classes.data.advancedManyToManyObjectRelation = Class.create(pimc
visibleFields: source.datax.visibleFields,
columns: source.datax.columns,
remoteOwner: source.datax.remoteOwner,
lazyLoading: source.datax.lazyLoading,
classes: source.datax.classes,
enableBatchEdit: source.datax.enableBatchEdit,
allowMultipleAssignments: source.datax.allowMultipleAssignments,
Expand Down
Expand Up @@ -32,10 +32,6 @@ pimcore.object.classes.data.advancedManyToManyRelation = Class.create(pimcore.ob

this.initData(initData);

if (typeof this.datax.lazyLoading == "undefined") {
this.datax.lazyLoading = true;
}

pimcore.helpers.sanitizeAllowedTypes(this.datax, "classes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "assetTypes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "documentTypes");
Expand Down Expand Up @@ -175,27 +171,6 @@ pimcore.object.classes.data.advancedManyToManyRelation = Class.create(pimcore.ob
disabled: this.isInCustomLayoutEditor(),
minValue: 0
},
{
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible(),
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible()
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_description'),
cls: "pimcore_extra_label_bottom",
style: "padding-bottom:0;"
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_warning_block'),
cls: "pimcore_extra_label_bottom",
style: "color:red; font-weight: bold;"
},
{
xtype: 'textfield',
width: 600,
Expand Down Expand Up @@ -593,7 +568,6 @@ pimcore.object.classes.data.advancedManyToManyRelation = Class.create(pimcore.ob
maxItems: source.datax.maxItems,
columns: source.datax.columns,
remoteOwner: source.datax.remoteOwner,
lazyLoading: source.datax.lazyLoading,
assetUploadPath: source.datax.assetUploadPath,
relationType: source.datax.relationType,
objectsAllowed: source.datax.objectsAllowed,
Expand Down
Expand Up @@ -64,8 +64,8 @@ pimcore.object.classes.data.block = Class.create(pimcore.object.classes.data.dat
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible(),
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible()
disabled: this.isInCustomLayoutEditor(),
checked: this.datax.lazyLoading
},
{
xtype: "checkbox",
Expand Down
Expand Up @@ -338,10 +338,6 @@ pimcore.object.classes.data.data = Class.create({
return this.inCustomLayoutEditor;
},

lazyLoadingNotPossible: function() {
return false;
},

setInClassificationStoreEditor: function(inClassificationStoreEditor) {
this.inClassificationStoreEditor = inClassificationStoreEditor;
},
Expand Down
Expand Up @@ -32,10 +32,6 @@ pimcore.object.classes.data.manyToManyObjectRelation = Class.create(pimcore.obje

this.initData(initData);

if (typeof this.datax.lazyLoading == "undefined") {
this.datax.lazyLoading = true;
}

pimcore.helpers.sanitizeAllowedTypes(this.datax, "classes");

// overwrite default settings
Expand Down Expand Up @@ -85,27 +81,6 @@ pimcore.object.classes.data.manyToManyObjectRelation = Class.create(pimcore.obje
disabled: this.isInCustomLayoutEditor(),
minValue: 0
},
{
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible(),
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible()
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_description'),
cls: "pimcore_extra_label_bottom",
style: "padding-bottom:0;"
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_warning_block'),
cls: "pimcore_extra_label_bottom",
style: "color:red; font-weight: bold;"
},
{
xtype: 'textfield',
width: 600,
Expand Down Expand Up @@ -240,7 +215,6 @@ pimcore.object.classes.data.manyToManyObjectRelation = Class.create(pimcore.obje
maxItems: source.datax.maxItems,
relationType: source.datax.relationType,
remoteOwner: source.datax.remoteOwner,
lazyLoading: source.datax.lazyLoading,
classes: source.datax.classes,
visibleFields: source.datax.visibleFields,
optimizedAdminLoading: source.datax.optimizedAdminLoading
Expand Down
Expand Up @@ -32,10 +32,6 @@ pimcore.object.classes.data.manyToManyRelation = Class.create(pimcore.object.cla

this.initData(initData);

if (typeof this.datax.lazyLoading == "undefined") {
this.datax.lazyLoading = true;
}

pimcore.helpers.sanitizeAllowedTypes(this.datax, "classes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "assetTypes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "documentTypes");
Expand Down Expand Up @@ -179,28 +175,6 @@ pimcore.object.classes.data.manyToManyRelation = Class.create(pimcore.object.cla
value: this.datax.maxItems,
minValue: 0
},
{
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible(),
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible()

},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_description'),
cls: "pimcore_extra_label_bottom",
style: "padding-bottom:0;"
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_warning_block'),
cls: "pimcore_extra_label_bottom",
style: "color:red; font-weight: bold; padding-bottom:0;"
},
{
xtype: 'textfield',
width: 600,
Expand Down Expand Up @@ -388,7 +362,6 @@ pimcore.object.classes.data.manyToManyRelation = Class.create(pimcore.object.cla
documentsAllowed: source.datax.documentsAllowed,
documentTypes: source.datax.documentTypes,
remoteOwner: source.datax.remoteOwner,
lazyLoading: source.datax.lazyLoading,
classes: source.datax.classes
});
}
Expand Down
Expand Up @@ -32,10 +32,6 @@ pimcore.object.classes.data.manyToOneRelation = Class.create(pimcore.object.clas

this.initData(initData);

if (typeof this.datax.lazyLoading == "undefined") {
this.datax.lazyLoading = true;
}

pimcore.helpers.sanitizeAllowedTypes(this.datax, "classes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "assetTypes");
pimcore.helpers.sanitizeAllowedTypes(this.datax, "documentTypes");
Expand Down Expand Up @@ -163,27 +159,6 @@ pimcore.object.classes.data.manyToOneRelation = Class.create(pimcore.object.clas
name: "width",
value: this.datax.width
} ,
{
xtype: "checkbox",
fieldLabel: t("lazy_loading"),
name: "lazyLoading",
disabled: this.isInCustomLayoutEditor() || this.lazyLoadingNotPossible(),
checked: this.datax.lazyLoading && !this.lazyLoadingNotPossible()
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_description'),
cls: "pimcore_extra_label_bottom",
style: "padding-bottom:0;"
},
{
xtype: "displayfield",
hideLabel: true,
value: t('lazy_loading_warning_block'),
cls: "pimcore_extra_label_bottom",
style: "color:red; font-weight: bold; padding-bottom:0;"
},
{
xtype: 'textfield',
width: 600,
Expand Down Expand Up @@ -367,7 +342,6 @@ pimcore.object.classes.data.manyToOneRelation = Class.create(pimcore.object.clas
assetUploadPath: source.datax.assetUploadPath,
relationType: source.datax.relationType,
remoteOwner: source.datax.remoteOwner,
lazyLoading: source.datax.lazyLoading,
classes: source.datax.classes,
objectsAllowed: source.datax.objectsAllowed,
assetsAllowed: source.datax.assetsAllowed,
Expand Down
2 changes: 0 additions & 2 deletions bundles/CoreBundle/Resources/translations/en.extended.json
Expand Up @@ -92,7 +92,6 @@
"composite": "Composite",
"origin": "Origin",
"high_resolution": "High Resolution",
"lazy_loading_warning_block": "WARNING: Lazy Loading is NOT possible within Blocks",
"pass_through_params": "Pass Through Params",
"redirects_type_entire_uri": "Entire URI",
"redirects_type_path_query": "Path and Query",
Expand Down Expand Up @@ -380,7 +379,6 @@
"user_apikey_description": "API key required for web service access by this user",
"apikey": "API Key",
"lazy_loading": "lazy loading",
"lazy_loading_description": "Lazy loading means that related objects are not loaded initially when the object is instantiated. When accessing the object programmatically, relations are only loaded when the according get method is called.",
"non_owner_description": "Non owner objects represent relations to an other object just in the same way as objects do. The difference is, that a non-owner object field is not the owner of the relation data, it is merely a view on data stored in other objects. Please choose the owner and field name where the data is originally stored.",
"allow_variants": "Allow variants",
"show_variants": "Show variants in tree",
Expand Down
Expand Up @@ -205,6 +205,9 @@ $object->setMetadata($references);


## Lazy Loading

> Note that from 6.5.0 on relations are always lazy loaded. The configuration option has been removed.

Whenever an object is loaded from database or cache, all these related objects are loaded with it. Especially with
Many-To-Many relations it is easy to produce a huge amount of relations, which makes the object or an object list slow
in loading.
Expand Down
Expand Up @@ -2,10 +2,13 @@


## 6.5.0
- Relation Types DB Caching Layer is always turned on now. Removed support for non-cached alternative.
- [Data Objects] Relations are always lazy-loaded from now on
see https://github.com/pimcore/pimcore/issues/5772
- [Data Objects] Relation Types DB Caching Layer is always turned on now. Removed support for non-cached alternative.
All rows of the affected `object_relation_` table will be fetched in on go and cached together we with the object.
see https://github.com/pimcore/pimcore/issues/5427
- If you have custom lazy-loaded datatypes **not** extending `Pimcore\Model\DataObject\ClassDefinition\Data\Relations\AbstractRelations`, implement the `LazyLoadingSupportInterface`
- [Data Objects] If you have custom lazy-loaded datatypes **not** extending `Pimcore\Model\DataObject\ClassDefinition\Data\Relations\AbstractRelations`,
implement the `Pimcore\Model\DataObject\ClassDefinition\Data\LazyLoadingSupportInterface`
The `method_exists('getLazyLoading')` calls will be removed in Pimcore 7.
- It is now possible to configure `php:memory_limit` for `web2print:pdf-creation` command with following configuration:
```yaml
Expand All @@ -17,7 +20,7 @@ pimcore:

- Using static methods for [dynamic text labels](../../05_Objects/01_Object_Classes/03_Layout_Elements/01_Dynamic_Text_Labels.md) is now deprecated, use services instead.
- Removed method `\Pimcore\Model\DataObject\ClassDefinition\Data\Relations\AbstractRelations::isRemoteOwner()`, as this method was only used for `ReverseManyToManyObjectRelation` internal check are now made using `instanceof`
- Data object inheritance skips now objects of other classes (so far only folders) so with an object path like `A (class Product) > B (other class) > C (class Product)` object C can inherit data from A.
- [Data Objects] inheritance skips now objects of other classes (so far only folders) so with an object path like `A (class Product) > B (other class) > C (class Product)` object C can inherit data from A.
- The built in cookie info bar (in system settings) is now marked as deprecated and will be removed in Pimcore 7.

## 6.4.0
Expand Down
6 changes: 5 additions & 1 deletion models/DataObject/ClassDefinition/Data/Block.php
Expand Up @@ -1183,7 +1183,11 @@ public function classSaved($class, $params = [])
foreach ($blockDefinitions as $field) {
if (($field instanceof LazyLoadingSupportInterface || method_exists($field, 'getLazyLoading'))
&& $field->getLazyLoading()) {
$field->setLazyLoading(false);

// Lazy loading inside blocks isn't supported, turn it off if possible
if (method_exists($field, 'setLazyLoading')) {
$field->setLazyLoading(false);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/ClassDefinition/Data/Localizedfields.php
Expand Up @@ -176,7 +176,7 @@ private function doGetDataForEditMode($data, $object, &$fieldData, &$metaData, $
$dataItems = $data->getInternalData(true);
foreach ($dataItems as $language => $values) {
foreach ($this->getFieldDefinitions() as $fd) {
if ($fd instanceof LazyLoadingSupportInterface && !DataObject\Concrete::isLazyLoadingDisabled() && $fd->getLazyLoading()) {
if ($fd instanceof LazyLoadingSupportInterface && $fd->getLazyLoading()) {
$lazyKey = $fd->getName() . DataObject\LazyLoadedFieldsInterface::LAZY_KEY_SEPARATOR . $language;
if (!$data->isLazyKeyLoaded($lazyKey)) {
$params['language'] = $language;
Expand Down