Bug reports Found a bug? Post it here please.
Version 4.x > Bug reports > Hotfix 4.0.2 breaks query string macros sometimes View modes: 
User avatar
Member
Member
mwinningham-global-id-group - 4/27/2009 5:20:33 PM
   
Hotfix 4.0.2 breaks query string macros sometimes
I just tried applying hotfix 4.0.2 and I noticed a bug with query string macros. It seems that now query string macros aren't resolved if the query string key is not in the URL.

For example, I have a blog with categories. In the repeater to show the blog entries, I set this as the WHERE condition:
('{%categoryid|(toint)0%}' = 0) OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentCategory WHERE CategoryID = {%categoryid|(toint)0%} ))


In Kentico 4.0 this worked correctly, but with the 4.0.2 hotfix it only works when I have "categoryid=something" in the URL.

This causes an error on the blog index page which has no query string. The query string macros don't get resolved and I get a database error because the query contains the unresolved macros.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/28/2009 7:57:38 AM
   
RE:Hotfix 4.0.2 breaks query string macros sometimes
Hi,

I have tried to reproduce your issue but with no luck, before and after the hotfix it is working fine. Could you please post here the error messages you are getting? Are you using any other customizations?
Thank you.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
mwinningham-global-id-group - 4/28/2009 12:04:32 PM
   
RE:Hotfix 4.0.2 breaks query string macros sometimes
Here is the stack trace:
[Exception: [DataConnection.ExecuteQuery]: Query: SELECT  * FROM View_CONTENT_BlogPost_Joined WHERE (((((SiteName = N'fcga_eu') AND (Published = 1)) AND (DocumentCulture = N'en-US')) AND (NodeAliasPath LIKE N'/Members-Area/News-Feed/%')) AND (('{%categoryid|(toint)0%}' = 0) OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentCategory WHERE CategoryID = {%categoryid|(toint)0%} )))) ORDER BY BlogPostDate DESC : caused exception: Incorrect syntax near '?'.]
CMS.DataProviderSQL.DataConnection.ExecuteQuery(String queryText, Object[,] queryParams, QueryTypeEnum queryType) +807
CMS.DataProviderSQL.DataConnection.CMS.IDataConnectionLibrary.IDataConnection.ExecuteQuery(String queryText, Object[,] queryParams, QueryTypeEnum queryType) +13
CMS.DataEngine.GeneralConnection.ExecuteQuery(String queryText, Object[,] parameters, QueryTypeEnum queryType, Boolean transaction) +171
CMS.DataEngine.GeneralConnection.RunQueryObject(Query query, Object[,] parameters) +325
CMS.DataEngine.GeneralConnection.RunQuery(String queryName, Object[,] parameters, String where, String orderBy, Int32 topN, String columns) +83
CMS.DataEngine.GeneralConnection.ExecuteQuery(String queryName, Object[,] parameters, String where, String orderBy, Int32 topN) +21
CMS.TreeEngine.TreeProvider.SelectNodes(String siteName, String aliasPath, String cultureCode, Boolean combineWithDefaultCulture, String classNames, String where, String orderBy, Int32 maxRelativeLevel, Boolean selectOnlyPublished, Int32 topN) +1219
CMS.Controls.CMSAbstractDataProperties.GetDataSet(String path, String where) +1421
CMS.Controls.CMSAbstractDataProperties.LoadData(Object& DataSource, Boolean forceReload) +120
CMS.Controls.CMSRepeater.ReloadData(Boolean forceReload) +1378
CMS.Controls.CMSRepeater.OnInit(EventArgs e) +374
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378


I have some custom user controls and web parts, but I tried disabling them so I don't think that is the problem; however, the problem does seem to be somehow related to ASPX templates:

When I first load my blog page (which uses a portal page template), it works correctly (even without the query string). Then, if I view its parent page (which uses an ASPX template) and go back to the blog, I get this error. The blog page will now give the error on every page load unless I add the categoryid to the query string. If I restart the website in IIS, the blog page will work again until I view the page with the ASPX template.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/30/2009 5:56:57 AM
   
RE:Hotfix 4.0.2 breaks query string macros sometimes
Hi,

Thank you for the details. I was able to reproduce the issue.

Could you please try to add this piece of code the the SetupControl() method in the repeater web part, right after the ELSE statement:

this.ContextResolver.KeepUnresolvedMacros = false;

This should help. I am sorry for the inconvenience.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
mwinningham-global-id-group - 4/30/2009 5:05:23 PM
   
RE:Hotfix 4.0.2 breaks query string macros sometimes
That worked, thanks!