Debug Dynamic Get option #50
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#50
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
I came across where a debug to echo the query(s) to screen on the site view would be really helpful in trying to track down an issue with a query, in particular filters in a query. (I'm still fighting this one).
My thought, and I wouldn't think this would be too difficult, is to add a radio option on the dynamic gets, it would just be a simple Yes(1) or No(0).
If yes, then on compile, the following (or something similar) would be added in the site view model, between $db->setQuery($query);
// [Interpretation 1781] Load the results as a stdClass object.
$data = $db->loadObject();
This line of code is // Dump the query
echo $db->replacePrefix((string) $query);
This would simple echo the query at the top of the site view, so it could more easily be debugged. If the radio is set to no, then that echo isn't included in the compile.
Thoughts?
I see your frustration, and I want to make it easier for all, yet try to avoid millions of switches...
Adding your suggested code will be simple, but I am thinking we should look further into a more complete debugging option of implementation. That gives info all over the component about many things that are usually not seen. Then to add one button on the compiler page that turns debugging on for that compile only... so it is easier to turn it on and off.
So I am thinking of one button on the compiler, that control all these debugging concepts. At this time it will only activate your request but as the project continues and more features like this is added we can use that one switch to turn it all on and off.
What do you think?
I think a global debug would be great. As another area is identified it can be expanded upon. This was just the first area that I encountered that it would be very helpful. This came about after spending hours of looking through code, looking through gets, then with that code quickly saw that it was the getint grabbing the category id rather than the item id.
Can't you just enable Debug mode on Joomla configuration? That will give you all the all the SQL instructions used for opening the page.
Just compile, install, run the component locally and you'll get what you need.
I was thinking about that (actually wrote it, lol but then removed it in my last post), I have not used it that much.
So let me see, we will add this echo to all components and only if the current Joomla has debugging enabled will it show the echo.. is that right?
I was saying not to code anything actually. Joomla already dumps SQL code when it has debug enabled.
Hmmm I understand, sorry little slow today... Like I said I thought it, but have not used it enough... @mwweb please take a look at this option and let me know if this resolves the issue for you.
The thing with the Joomla! debug is that it outputs every single query, even if it doesn't pertain to the component. In my case, there are 26 queries logged, so each time I do a build, it sifting through 26 queries to get to the one(s) I'm looking for.
However, with the echo, it outputs to screen only the queries that pertain to the view, making it much quicker in my opinion.
There is a simple way to implement this.
Let's use the Debug lines compiler option.
#If debug is enabled add this code to the beginning of the display() function of controller of the created component (site and admin)
#endif
Please review the code for the component name (without the 'com_') in the search part as I'm not familiar on which is the correct code to use.
Only tested it in admin but I'm guessing in site it will also work.
@mwweb You can use it right now if you need it while @Llewellynvdm adds it to JCB. Just replace ###component_name### with your component's name
@mwweb will this work for you? have you tested the code @Peeripapo gave... I will add it if it works.
This way the details will show if debugging is enabled in the Joomla global config.
It looks as though it is creating an area at the bottom of the page, labeled JCB SQL Queries, but nothing is being generated.
@mwweb did you change ###component_name### part to your components name ?
After implementing on JCB this can be automatic but for testing you need to hardcode it.
@Llewellynvdm I'd suggest adding an extra radio button in the compile view so we can distinguish visual debugging from code debugging. This will come handy on future debug actions.
On categories it works fine, but not on other queries. As an example, a view that is displaying all records from company table, shows the below, rather than the query:
JCB SQL Debug
What are you replacing ###component_name### with ?
In my case, my component is com_mostwantedrealestate, and that is what I'm replacing ###component_name### with.
Okay I have not implemented anything as yet, I just have not had the time.
But if you can come with a ready script (that is tried and tested) that will work for each site and custom admin view that makes use of the DynamicGet DB query builder.
Then I will make the effort to add it.
At this time it seems best that the script should auto show if debugging is turned on in the Joomla global settings.
Thanks for your help in this regard 👍
@mwweb Try it without the "com_" prefix, just : "mostwantedrealestate". That should do it.
@Llewellynvdm it is working OK, it's the prefix that shouldn't be used in the replacement part. Using it along with joomla global debug seems fine to me for now. I'll fix the code to reflect that condition.
OK, it appears to be working correctly. It actually, kind of, showed me where to start digging on my of my views that is having issues.
Where are we with this? do you have a local repo or some code snippet I can look at?
@Peeripapo it seems little heavy to have the above code run each time a view is loaded... can you streamline it some more?
Please show me a view.html.php with this code in action.