Header compiler plugin creates incorrect output in (site)admin views #972

Closed
opened 2023-02-01 13:27:04 +00:00 by SimonvanDoorne · 8 comments
Member

Steps to reproduce the issue

  1. Select default template header in class headers to compile
    image
  2. Build

Expected result

image

Actual result

image
Problem 1) The ordering is wrong.
You can't put code in the view and then use the 'use' keyword. The header compiler plugin does the following:
image
Clearly loading the text from the textarea first, then the 'use' cases. I understand this works on a lot of other pages so i don't understand why it doesn't work here (or rather does work on other pages)

Problem 2) missing closing bracket
image
Line 631 shows removing duplicate lines,causing the last bracket to not render since it's a duplicate of a different line. I understand now i could just change my code, and will do that now but it's still difficult to work around.

System information (as much as possible)

### Steps to reproduce the issue 1) Select default template header in class headers to compile ![image](/attachments/8d19ff06-2496-4ebb-9135-13144e40db43) 2) Build ### Expected result ![image](/attachments/fc7df82f-72f9-4738-97eb-e741a54601c7) ### Actual result ![image](/attachments/fbd75a73-0053-49bd-94da-476bd6010b26) Problem 1) The ordering is wrong. You can't put code in the view and then use the 'use' keyword. The header compiler plugin does the following: ![image](/attachments/6566f466-2897-4f31-9f73-75c2ba30a3e7) Clearly loading the text from the textarea first, then the 'use' cases. I understand this works on a lot of other pages so i don't understand why it doesn't work here (or rather *does* work on other pages) Problem 2) missing closing bracket ![image](/attachments/bde464c0-2751-4c6d-81e9-a29b126b750f) Line 631 shows removing duplicate lines,causing the last bracket to not render since it's a duplicate of a different line. I understand now i could just change my code, and will do that now but it's still difficult to work around. ### System information (as much as possible) - JCB Version: Latest version from this https://git.vdm.dev/joomla/pkg-component-builder/archive/master.zip link - Browser: Any
Owner

Hi @SimonvanDoorne, trust your doing well.

Okay so the header area was not intended to be used for code, but for adding use namespace/classes to areas where you would like to use those classes.

That said, you can add code there, not ideal... but possible.

The current ordering places the powers second, and the header first... hmmm we are not really managing the ordering directly. I think it just end-up this way after being processed.

I looked at the code and we can in the plugin, just swap a few lines inside the getHeaders method to change the ordering.

So looking at line 578-602 you will see we are first loading the text, and then the powers. Just swap those around, and let me know if it resolves the issue. Once confirmed I can push the change out with the next update.

Hi @SimonvanDoorne, trust your doing well. Okay so the header area was not intended to be used for code, but for adding `use namespace/classes` to areas where you would like to use those classes. That said, you can add code there, not ideal... but possible. The current ordering places the powers second, and the header first... hmmm we are not really managing the ordering directly. I think it just end-up this way after being processed. I looked at the code and we can in the [plugin](https://git.vdm.dev/joomla/plg_extension_componentbuilderheaderscompiler), just swap a few lines inside the [getHeaders](https://git.vdm.dev/joomla/plg_extension_componentbuilderheaderscompiler/src/branch/master/componentbuilderheaderscompiler.php#L570) method to change the ordering. So looking at [line 578-602](https://git.vdm.dev/joomla/plg_extension_componentbuilderheaderscompiler/src/branch/master/componentbuilderheaderscompiler.php#L578-L602) you will see we are first loading the text, and then the powers. Just swap those around, and let me know if it resolves the issue. Once confirmed I can push the change out with the next update.
Author
Member

Hi Llewellyn,

Thanks for the response, i had a feeling i was using this area in unintended ways so i'm not surprised it didn't work right out of the gate :). The links you post give me a 404 page, and i can't find the repo through git/vdm/google either. Is it possible the repo is private?

Hi Llewellyn, Thanks for the response, i had a feeling i was using this area in unintended ways so i'm not surprised it didn't work right out of the gate :). The links you post give me a 404 page, and i can't find the repo through git/vdm/google either. Is it possible the repo is private?
Owner

Yes its private... I have now given you access.

Yes its private... I have now given you access.
Author
Member

I still get a 404 image
The link to the repo is https://git.vdm.dev/joomla/plg_extension_componentbuilderheaderscompiler right? Just checking if i'm not making any typos.

I still get a 404 ![image](/attachments/00aaef15-4b1d-4f44-8347-a4401e7ff49b) The link to the repo is https://git.vdm.dev/joomla/plg_extension_componentbuilderheaderscompiler right? Just checking if i'm not making any typos.
Owner

Hmmm not sure, let me check the permissions, one moment. My apologies... try again.

Hmmm not sure, let me check the permissions, one moment. My apologies... try again.
Author
Member

I have access now, thanks! I'm going to check the suggestions later today!

I have access now, thanks! I'm going to check the suggestions later today!
Owner

I already made the changes, and it should reflect with the next stable release.

I already made the changes, and it should reflect with the next stable release.
Owner

As we now have a beta branch with all the latest fixes, I will direct you to it and consider this issue resolved. If you discover that the beta branch does not address the issue, please leave a comment here explaining what you found, and I will reopen this issue.

https://git.vdm.dev/joomla-beta/pkg-component-builder/archive/master.zip

As we now have a beta branch with all the latest fixes, I will direct you to it and consider this issue resolved. If you discover that the beta branch does not address the issue, please leave a comment here explaining what you found, and I will reopen this issue. https://git.vdm.dev/joomla-beta/pkg-component-builder/archive/master.zip
Robot referenced this issue from a commit 2023-02-27 09:43:15 +00:00
Robot referenced this issue from a commit 2023-02-27 12:28:17 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#972
No description provided.