Problem with Export/Import of components Field mapping #587
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#587
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Steps to reproduce the issue
Export component which uses SUBFORM fields and ADMIN FIELD RELATIONS from Development Site A
Import component to Development site B.
Expected result
Field ID mappings in Development site B in SUBFORM fields and ADMIN FIELD RELATIONS correctly reflect new IDS as a result of changes in IDs during import.
Please see Additional comments below for detail explanation.
Actual result
Field IDS on Development Site B in SUBFORM fields and ADMIN FIELD RELATIONS still reflect original field IDS as per Development Site A
Please see Additional comments below for detail explanation.
System information (as much as possible)
• OS Name & Version: Win10Pro
• MySql Version: 5.5.5-10.4.13-MariaDB
• Apache Version: 2.4.41 win 64b
• PHP Version: 7.4.8
• Joomla Version: 2.9.20
• JCB Version: 2.11.4 and earlier…
• Browser: Firefox 75.0 64b
Additional comments
To simplify the problem, I will try to illustrate it by using the following example.
I use JCB do develop a NEW component on a localhost in Win 10 using Xampp on Laptop A.
It is a "clean" system with only Joomla, Akeeba, JCB Component Builder installed and the components Demo (public) and Field Type Updater (public) imported.
The NEW component has a single admin view with the following fields:
Field ID, Field Type, Name, Label, Property 'fields' used in Subform
50, Text, Txt_First, First Name,
51, Text, Txt_Last, Last Name,
52, Subform, Sf_Address, Address, 53,54,55
53, Text, Txt_Street, Street,
54, Text, Txt_Town, Town,
55, Text, Txt_Zip, Zip,
The Admin View Field Relations has the following definition:
List Field, Column Name, Join field, Area, Join Type, Set
Txt_First, Full Name, Txt_Last, View, Custom Code, [field=51],[field=50]
Sofar so good, I test component and it works fine….
Then I export component on Computer A and import into JCB installation on COMPUTER B.
Please note that Computer B has Joomla and components JCB Component Builder, Demo (public) and Field Type Updater (public) AND 2 other JCB components already installed.
The fields imported into JCB on computer B now reflect the following fields:
Field ID, Field Type, Name, Label, Property 'fields' used in Subform
95, Text, Txt_First, First Name,
96, Text, Txt_Last, Last Name,
97, Subform, Sf_Address, Address, 53,54,55 (Note that the FIELD IDS are still those from Computer A)
98, Text, Txt_Street, Street,
99, Text, Txt_Town, Town,
100, Text, Txt_Zip, Zip,
The Admin View Field Relations still reflects the Computer A field definitions:
List Field, Column Name, Join field, Area, Join Type, Set
Txt_First, Full Name, Txt_Last, View, Custom Code, [field=51],[field=50]
If I compile and run the component I have errors in the list view shows only the text '[field=51],[field=50]' in the "Full Name" column and the SUBFORM do not reflect the correct fields.
I have to manually REMAP and update:
• the field IDs for the SUBFORM ‘Sf_Address’ to now read ‘89,99,100’ and
• the Field Relations ‘Set’ in the Admin Relations View to reflect the code ‘[field=96],[field=95]’.
This is a simplistic example, but it is typical of the issues I am experiencing with my components which are in development. Subform fields and Field Relations do not change to reflect new field IDs.
According to recent discussions with Lewellyn this should not be happening, but it still is...
What I am doing, which maybe impacting this, is that I also create new FIELD TYPES based on existing JCB FIELD TYPES, mainly because I add extra XML fields to the FIELD TYPE which I need in my coding. I then use the new FIELD TYPE as a basis for some of my fields…
..for example, I predefine a CUSTOM field with additional XML field to set up filters when listing records…and then I read this XML field in the coding of the FIELD TYPE to filter data for the list. I then use this new FIELD TYPE as a bases for many different custom FIELDS.
However, I have tried the above export and import actions with just using standard JCB FIELD TYPES and the problem is still happening.
It seems to me, that the even though the JCB export/import remaps field IDS correctly for ADMIN VIEWS and their corresponding views, this remapping does not seem to happen a SUBFORM field (in the XML property 'fields') or the FIELD RELATIONS VIEW…
The only time I do not need to REMAP is if I import onto Computer B which has a JOOMLA/JCB set up identical to Computer A before I created the component…because then the ‘imported’ field IDs are identical on Computer B to those on Computer A, and no remapping is required.
I am finding this a BIG problem as I tend to test my components on a separate environment and each time I move the component (export/import) I have to manually remap all the fields on the imported environment…and this is a lot of work if one uses a many subforms and/or admin relations functionality, which I tend to do....
I can work around the admin relations view by hard coding the relevant info eg. "echo $item->txt_last . ',' . $item->txt_first", but this does not solve the issue with subforms...
So, has anyone else experienced this problem? Any suggestions as to what I might be doing incorrectly? Any ideas how I can make this export/import process simpler...
Thanks
@duetnet thank you for the clear explanation. My problem is that I have not been able to replicate this issue, since all JCB packages, like JCB itself and other are imported with the same remapping engine and it does indeed remap sub-forms, and relations correctly.
So one option, share with us a basic JCB packages that you don't mind sharing. Then I can import it into a black Joomla with a new JCB and see what happens, since the moment I can replicate the issue I can fix it. Until then it is very hard to see what goes wrong.
Lets fix this issue so you can spend your time one more important things then remapping ID's ugghh..
@Llewellynvdm
I have spent the last 2 days trying to prove what I claimed above, by creating a component with a single view using a subform, exporting and importing and just could not find a fault with the remapping…
So I went back to my original component import/export and tried to understand what went wrong and I have a clue, but it is hard to prove other than providing you with the actual export and import field lists as per my spreadsheet…
DuetNet_Component_Export_Import_Matching.xlsx
I will try to explain (please refer to attached spread sheet).
Each PC listed starts off with Joomla standard, JCB Component Builder and components Demo (public) and Field Type Updater (public). My component is the next component created….
When I export from PC A (see worksheet Compare – columns ‘PC A Bef export’), all the field are listed in ID sequence. PC A was still using JCB v 2.11.2 and Field Updater 2.9.22 and Demo 2.0.1.
All the subforms are field type 43. There are 13 subform fields in total. The first subform appears at ID 1140 (note the XML Fields and their IDS).
Fields 23 to 1051 are JCB fields. My fields start at 1052.
Also note that export shows 3 extra fields, i.e.
PC B is set up with JCB v 2.11.3 and Field Updater 2.9.22 and Demo 2.0.3.
I export the Package from PC A and then import the Package into PC B (see worksheet Compare – ‘PC B 1st import’)
Fields 23 to 1048 are JCB fields. My fields start at 1049.
Note that the extra JCB fields on PC A (1024, 1049 and 1050) are missing on PB C.
The field name sequences between PC A export and PC B import correspond from PC A field 1052 to 1343, but from PC A field IDs 1344, the field names sequence differs between PC A export and PCB import. I think this may be because of the sequence in which I had originally created the fields and also the sequence of the admin views on PC A (which I had changed at some time earlier).
With the import, it seems that the fields get sequenced in the order which they are used in the admin view. (Not sure, just a guess!!)
If you go to the first subform (PC A field 1140) you will see it is field 1137 on PC B.
NOW Note that the XML Fields on PC B are the SAME as on PC A, although the actual fields on PC B have different IDs, So the fields have not been remapped in the subforms.
If you check ALL the subforms between PC A export and PC B import you will see the same issue has happened throughout. (the field references in the Admin View Relations have also not changed, just too much info to list here)
I then manually reworked/remap all the subform XML fields and field conditions in PC B and created an package export (see worksheet Compare – ‘PC B reworked & exported’)
I then set up PC C with JCB v 2.11.4 and Field Updater 2.9.22 and Demo 2.0.3.
This is where I attempted to create a single admin view as per my original example about the issue…but could not get the same effect and the trashed all my examples…
I decided to import to PC C the exported package from PC B.
The result is worksheet Compare – ‘PC C 1st import’. Because of the previous example attempts, my fields for the component imported from PC B only start at ID # 1075.
Nevertheless, you will note that all the subform fields (and the Admin View Relations) are correctly renumbered with the new numbers….so the remapping has now worked correctly!!!
So..in conclusion..
It appears that:
My only clues are
Sorry, this is my best attempt at trying to determine what is causing my issue.
If you wish I can forward you my entire PC A export to see if you can debug the import. Please let me know.
Thanks again for your time (and for JCB :-))
Sorry, accidentally close this issue..
Wow very detailed explanation!
Well from my point of view that ids starting point does not play a roll at all. I could explain how the import ID remapping works to show you that the IDs should not play a roll. But if the fields used in the subforms from PC A in the first place are not exported this could be a problem.
I remember telling you where to jump into the export and see the actual data-set before JCB locks the data. This will help you see if what fields are exported from PC A in the first place. Just as a reminder:
On /models/joomla_components.php line 1077 replace the comment with:
Then look at the fields array for the ID's from your subform fields, are they being exported? Should this be the point of failure that we need not look at the importer remapping the ID's. Then this will main we have a miss on the export.
Let see what this turns up.
Hi Llewellyn
I have done the var_dump on PC A as explained by you, herewith my findings..with reference to the spread sheet I sent on Saturday..
The var_dump does not list all the fields, only lists 126 fields (out of my total of 312 fields) , from ID 1052 to 1177 and then shows message ‘ more elements...' and then continues with ‘component_custom_Admin_views’
So in the range listed, only subform field 1140 and its subfields appear correctly as per my spreadsheet, but this is only the export. I attach that section of the dump.
I also include the export of the actual Admin view in which subform field 1140 is used, but again, var_dump seems to cut off the ‘addfields’ row so I do not see the field actually being used….
I know you mention that you do not use IDs for remapping, but I must confess, everything in this extract is linked to an original extracted ID so I am fascinated as to how you do the remapping..
Tried to read through import process and I know it happens somewhere in import_joomla_components @ line 745, or 1619 and does appear to do an id remapping here, just not sure where decipher to see how it treats subforms and field relations on import…
Hope this helps
Regards
Franz
The note on the browser saying
more elements...
means that your debugger, or is limiting the length of a string being printed out. One way around this is to instead loop over the fields array and print one field ID at a time instead, just so you can see all the values. themore elements...
means there are more, they are just not being printed.There is an array in the import class that keeps track of all ID's called
$this->newID
you can see this array in action in thesetNewID
(here) function, but it is populated all over the architecture when ever a new ID's is found. The reality is the order of the tables being updated is part of the architecture that makes this work. Then there is the way the JCB finds the fields, or any items for that matter in the the new system, you can see this search in the connection of three functionssaveSmartItems
(here),getLocalItem
(here), andaddLocalItem
(here). Then we also have a delayed remapping where we can't know values head of time, and need to work back-wards as it where to in affect first create the items, and then go back after the fact and update values in various columns and rows as needed. This is done with theupdateAfterAll
(here) function.So searching for the
$this->newID
in the import class will take you to various moments in the execution where ID's are mapped. Really simple actually, based on table names and ideal moments this$this->newID
is populated.Next we of course need to look at the
updateSubformsIDs
(here) andupdateSubformIDs
(here) which again is called from many areas/moments during the import. Specially in theprepItem
(here) function which is always trigger before any item is found/updated, or created.Then there is this value called
$diverged
which is used when data diverged, so you may ask, when are values seen as diverged, well good question. JCB moved data from table to other tables over the years, and this diverged method is just to move component packages from before this move, to the new locations. This works very well actually since I have a few very old packages I still move around when needed.Then at last we have the ID re-mapper
setNewID
(here) that actually remaps all ID's for all fields and field types based on table, and target field, this function is also called from all over the place as needed.This should give you enough to understand. Let me know about the full list of exported ID's.
Thanks for detailed explanation. I will debug imporer accordingly to see if I can find where my problem occurs.FranzSent from my Samsung device
-------- Original message --------
From: Llewellynvdm notifications@github.com
Date: 2020/08/18 05:30 (GMT+02:00)
To: vdm-io/Joomla-Component-Builder Joomla-Component-Builder@noreply.github.com
Cc: Franz hfdewet@mweb.co.za, State change state_change@noreply.github.com
Subject: Re: [vdm-io/Joomla-Component-Builder] Problem with Export/Import of
components Field mapping (#587)
The note on the browser saying more elements... means that your debugger, or is limiting the length of a string being printed out. One way around this is to instead loop over the fields array and print one field ID at a time instead, just so you can see all the values. the more elements... means there are more, they are just not being printed.
Okay lets explain in simple terms how the remapped works.
There is an array in the import class that keeps track of all ID's called $this->newID you can see this array in action in the setNewID(here) function, but it is populated all over the architecture when ever a new ID's is found. The reality is the order of the tables being updated is part of the architecture that makes this work. Then there is the way the JCB finds the fields, or any items for that matter in the the new system, you can see this search in the connection of three functions saveSmartItems(here), getLocalItem(here), and addLocalItem(here). Then we also have a delayed remapping where we can't know values head of time, and need to work back-wards as it where to in affect first create the items, and then go back after the fact and update values in various columns and rows as needed. This is done with the updateAfterAll(here) function.
So searching for the $this->newID in the import class will take you to various moments in the execution where ID's are mapped. Really simple actually, based on table names and ideal moments this $this->newID is populated.
Next we of course need to look at the updateSubformsIDs(here) and updateSubformIDs(here) which again is called from many areas/moments during the import. Specially in the prepItem(here) function which is always trigger before any item is found/updated, or created.
Then there is this value called $diverged which is used when data diverged, so you may ask, when are values seen as diverged, well good question. JCB moved data from table to other tables over the years, and this diverged method is just to move component packages from before this move, to the new locations. This works very well actually since I have a few very old packages I still move around when needed.
Then at last we have the ID re-mapper setNewID(here) that actually remaps all ID's for all fields and field types based on table, and target field, this function is also called from all over the place as needed.
This should give you enough to understand. Let me know about the full list of exported ID's.
—You are receiving this because you modified the open/close state.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/vdm-io/Joomla-Component-Builder/issues/587#issuecomment-675228429",
"url": "https://github.com/vdm-io/Joomla-Component-Builder/issues/587#issuecomment-675228429",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
I have just upgraded to JCB V2.11.4
Dont know what you may have changed, but I ran an export from V2.11.2, ran an import into V2.11.4 and mapping worked perfectly!!!
Tried to debug on the older version, but just kept getting lost in the debugging and gave up as it had taken up too much of my time already...was quicker to manually remap 👍
But, thanks anyway for your all your feedback, it did clarify things for me and was very much appreciated..
Hi Llewellyn
Sorry to reopen this issue, I experienced the problem again and I think I may now have a handle on what is happening.
First clue....
Second clue..
Although I am not sure how the admin view sequence is exported and imported, this may also be an issue.
I have noticed that if I change the sequence of admin views in my exporting component's config, then the import sequence in the imported admin view list changes, however this sequence of the ID#s in import system is not necessarily the sequence in which they appear in the component config, but it has changed. (Simple example, I add a new admin view, placed it 3rd in the list of admin views, or I move an admin view up or down in the list of component admin views)
Nevertheless, when I now look at the sequence in which fields are imported, it appears that they are imported in the following sequence
If I change the admin view sequence, this appears to impact the subform mapping....
Approach used to prove this...
I use the same approach when changing admin view sequence in the component and sometimes this affects the subform but not every time and I have not yet established a pattern....will try to pin it down.
After listening on high speed the last JUG... I realize I have not touched on this issue again in a long time, besides that I have in fact implemented the GUID import option in v2.12.11 for all tables that has GUID field.
Would be interesting to see if this improvement to this area has helped.