Admin view with no fields breaks table creation #983

Closed
opened 2023-02-28 22:07:44 +00:00 by Chris Paschen · 5 comments
Member

Steps to reproduce the issue

  1. Create some fields
  2. Create an Admin View
  3. FORGET to add the fields to the admin view
  4. Add the admin view to the component
  5. Compile
    RESULT: Try to open table and error given that the table doesn't exist; the table was not created in the db; no 'CREATE TABLE' in the JCB Components Update view
  6. Open the admin view and add the fields that were forgotten
  7. Compile
    EXPECTED RESULT: Table created with fields
    ACTUAL RESULT: Table NOT created; no entries at all for the table appear in the Component's Update area in JCB
  8. Try renaming the admin view (just to see if that might get JCB to create the table)
    RESULT: in JCB Components Update view a 'RENAME TABLE' update is listed (but still no 'CREATE TABLE') so table doesn't exist
  9. Completely delete the old admin view
  10. Create a new one (with new Names (single record/list of records) that is different from previously used
  11. Add fields and add to component
  12. Compile
    RESULT: Table is created as it should

The question is why, after step 7 above did the table not get created once fields were added?
Is there a way to add fields to an admin view and have it create the table properly after it has previously been compiled with an empty admin view?
If not, is there a way to 'flag' an empty (no fields) admin view to avoid compiling a component with an empty admin view?

System information (as much as possible)

  • OS Name & Version: Windows 10 / WAMP
  • MySql Version: 5.7.31
  • Apache Version: 2.4.46
  • PHP Version: 7.4.9
  • Joomla Version: 3.10.11
  • JCB Version: 3.1.12, also same results on 3.1.15 and 3.1.19
  • Browser: Firefox Developer

Additional comments

I've tested this on a couple different sites (all with same WAMP servers specs)

This isn't a 'critical' issue (actually a pretty low priority item) as I would hope that I don't accidentally forget to add the fields again, but it is a pretty frustrating bind to get in to have to completely remove the admin view (and have to come up with a completely different view name) when you forget to add the fields at first.

### Steps to reproduce the issue 1. Create some fields 2. Create an Admin View 3. FORGET to add the fields to the admin view 4. Add the admin view to the component 5. Compile RESULT: Try to open table and error given that the table doesn't exist; the table was not created in the db; no 'CREATE TABLE' in the JCB Components Update view 6. Open the admin view and add the fields that were forgotten 7. Compile EXPECTED RESULT: Table created with fields ACTUAL RESULT: Table NOT created; no entries at all for the table appear in the Component's Update area in JCB 8. Try renaming the admin view (just to see if that might get JCB to create the table) RESULT: in JCB Components Update view a 'RENAME TABLE' update is listed (but still no 'CREATE TABLE') so table doesn't exist 9. Completely delete the old admin view 10. Create a new one (with new Names (single record/list of records) that is different from previously used 11. Add fields and add to component 12. Compile RESULT: Table is created as it should The question is why, after step 7 above did the table not get created once fields were added? Is there a way to add fields to an admin view and have it create the table properly after it has previously been compiled with an empty admin view? If not, is there a way to 'flag' an empty (no fields) admin view to avoid compiling a component with an empty admin view? ### System information (as much as possible) - OS Name & Version: Windows 10 / WAMP - MySql Version: 5.7.31 - Apache Version: 2.4.46 - PHP Version: 7.4.9 - Joomla Version: 3.10.11 - JCB Version: 3.1.12, also same results on 3.1.15 and 3.1.19 - Browser: Firefox Developer ### Additional comments I've tested this on a couple different sites (all with same WAMP servers specs) This isn't a 'critical' issue (actually a pretty low priority item) as I would hope that I don't accidentally forget to add the fields again, but it is a pretty frustrating bind to get in to have to completely remove the admin view (and have to come up with a completely different view name) when you forget to add the fields at first.
Member

I have always tried to stop Llewellyn from creating this particular automation. Nonetheless, he insisted on doing so and now it has become a pain. Let me tell you, it's all thanks to that blasted Joomla history component. Have you reviewed his in-depth explanation on why things tend to go awry on this? If you watch it again, I'm almost certain that you will recognize where you're going wrong, and get the timing just wrong.

I have always tried to stop Llewellyn from creating this particular automation. Nonetheless, he insisted on doing so and now it has become a pain. Let me tell you, it's all thanks to that blasted Joomla history component. Have you reviewed his in-depth explanation on why things tend to go awry on this? If you watch it again, I'm almost certain that you will recognize where you're going wrong, and get the timing just wrong.
Member
Here you go https://youtu.be/55U8FDlLI7Q
Owner

@cpsachen I have done a quick test in this area, and I see we may have a real issue. Will update you once I know more.

@cpsachen I have done a quick test in this area, and I see we may have a real issue. Will update you once I know more.
Author
Member

@Llewellyn I don't personally think this is all that critical to deal with right now (unless it makes sense to do so from a coding perspective). I would think just a 'check' process that maybe even just aborts the compile if there is an admin view with not fields would do the trick.
But until you get a good break in the more involved code, maybe just a text on the compile page to say "Slow down and check your work" would do :-)

Considering how many admin views I have created over the past few years in JCB, I'm surprised that I didn't do this before. But that just goes to show that IF you watch the JCB youtube videos and just take time and be careful we can avoid this (until you have time to come up with a way to prevent the issue.

Thanks for all your work on JCB!

@Llewellyn I don't personally think this is all that critical to deal with right now (unless it makes sense to do so from a coding perspective). I would think just a 'check' process that maybe even just aborts the compile if there is an admin view with not fields would do the trick. But until you get a good break in the more involved code, maybe just a text on the compile page to say "Slow down and check your work" would do :-) Considering how many admin views I have created over the past few years in JCB, I'm surprised that I didn't do this before. But that just goes to show that IF you watch the JCB youtube videos and just take time and be careful we can avoid this (until you have time to come up with a way to prevent the issue. Thanks for all your work on JCB!
Owner

If we don't fix bugs as we go, it will pile up and fall on us 👍

So its a big deal... and I need to fixed, as I am using this everyday. I think I found the issue.

Try this in Updatesql.php on line 223-233 make the following change:

// convert admin view id to name
if ('adminview' === $type)
{
	$this->registry->set('builder.add_sql.' . $type . '.' . $this->name($item),
		$item
	);
}
else
{
	$this->registry->set('builder.add_sql.' . $type, $item);
}

So we make the name part of the path, this should resolve it.

Can you do me another favor? Please check that all changes (that should trigger a DB update) do trigger a DB update.

This fix will be in the next release, but is already be in the beta build.

If we don't fix bugs as we go, it will pile up and fall on us 👍 So its a big deal... and I need to fixed, as I am using this everyday. I think I found the issue. Try this in [Updatesql.php](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Updatesql.php) on line [223-233](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Updatesql.php#L223-L233) make the following change: ``` // convert admin view id to name if ('adminview' === $type) { $this->registry->set('builder.add_sql.' . $type . '.' . $this->name($item), $item ); } else { $this->registry->set('builder.add_sql.' . $type, $item); } ``` So we make the name part of the path, this should resolve it. Can you do me another favor? Please check that all changes (that should trigger a DB update) do trigger a DB update. This fix will be in the next release, but is already be in the [beta build](https://git.vdm.dev/joomla-beta/pkg-component-builder/archive/master.zip).
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#983
No description provided.