Skip to content

Commit 2f9f90b

Browse files
committed
Various fixes & enhancements
1 parent a3fa354 commit 2f9f90b

10 files changed

Lines changed: 330 additions & 30 deletions

File tree

src/Libraries/SmartStore.Core/Caching/OutputCache/OutputCacheItem.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public class OutputCacheItem : ICloneable<OutputCacheItem>
1717
public string QueryString { get; set; }
1818
public int Duration { get; set; }
1919
public string[] Tags { get; set; }
20-
public string ETag { get; set; }
2120

2221
public string Theme { get; set; }
2322
public int StoreId { get; set; }

src/Libraries/SmartStore.Core/Collections/Querystring.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public QueryString FillFromString(string s, bool urlDecode = false)
7777
string[] split = keyValuePair.Split('=');
7878
base.Add(split[0], split.Length == 2 ? (urlDecode ? HttpUtility.UrlDecode(split[1]) : split[1]) : "");
7979
}
80+
8081
return this;
8182
}
8283

src/Libraries/SmartStore.Core/Fakes/FakeHttpRequest.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,10 @@ public FakeHttpRequest(string relativeUrl,
3232
{
3333
_httpMethod = method;
3434
_relativeUrl = relativeUrl;
35-
_formParams = formParams;
36-
_queryStringParams = queryStringParams;
37-
_cookies = cookies;
38-
_serverVariables = serverVariables;
39-
//ensure collections are not null
40-
if (_formParams == null)
41-
_formParams = new NameValueCollection();
42-
if (_queryStringParams == null)
43-
_queryStringParams = new NameValueCollection();
44-
if (_cookies == null)
45-
_cookies = new HttpCookieCollection();
46-
if (_serverVariables == null)
47-
_serverVariables = new NameValueCollection();
35+
_formParams = formParams ?? new NameValueCollection();
36+
_queryStringParams = queryStringParams ?? new SmartStore.Collections.QueryString().FillFromString(relativeUrl);
37+
_cookies = cookies ?? new HttpCookieCollection();
38+
_serverVariables = serverVariables ?? new NameValueCollection();
4839
}
4940

5041

src/Plugins/SmartStore.DevTools/Controllers/DevToolsController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@ public ActionResult Configure(ConfigurationModel model, ProfilerSettings setting
3737
return RedirectToConfiguration("SmartStore.DevTools");
3838
}
3939

40+
[ChildActionOnly]
4041
public ActionResult MiniProfiler()
4142
{
4243
return View();
4344
}
4445

46+
[ChildActionOnly]
4547
public ActionResult MachineName()
4648
{
4749
ViewBag.EnvironmentIdentifier = Services.ApplicationEnvironment.EnvironmentIdentifier;
4850

4951
return View();
5052
}
51-
53+
54+
[ChildActionOnly]
5255
public ActionResult WidgetZone(string widgetZone)
5356
{
5457
var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext);

src/Presentation/SmartStore.Web.Framework/Filters/CookieConsentFilter.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void OnActionExecuting(ActionExecutingContext filterContext)
135135
}
136136
}
137137

138-
filterContext.Controller.ViewBag.CookieConsentStatus = _consentStatus;
138+
filterContext.HttpContext.Items[CookieConsent.ConsentCookieName] = _consentStatus;
139139
}
140140

141141
public void OnActionExecuted(ActionExecutedContext filterContext)
@@ -151,14 +151,12 @@ public void OnResultExecuting(ResultExecutingContext filterContext)
151151
if (!filterContext.Result.IsHtmlViewResult())
152152
return;
153153

154-
if (_consentStatus < CookieConsentStatus.Consented)
155-
{
156-
_widgetProvider.Value.RegisterAction(
157-
new[] { "body_end_html_tag_before" },
158-
"CookieConsentBadge",
159-
"Common",
160-
new { area = "" });
161-
}
154+
// Always render the child action because of output caching
155+
_widgetProvider.Value.RegisterAction(
156+
new[] { "body_end_html_tag_before" },
157+
"CookieConsentBadge",
158+
"Common",
159+
new { area = "" });
162160
}
163161

164162
public void OnResultExecuted(ResultExecutedContext filterContext)
@@ -186,9 +184,20 @@ public static void SetCookie(HttpResponseBase response, CookieConsentStatus stat
186184
response.Cookies.Set(consentCookie);
187185
}
188186

189-
public static CookieConsentStatus GetStatus(ViewContext context)
187+
public static CookieConsentStatus GetStatus(ControllerContext context)
190188
{
191-
return context.ViewBag.CookieConsentStatus ?? CookieConsentStatus.Unset;
189+
if (context.HttpContext.Items.Contains(ConsentCookieName))
190+
{
191+
return context.HttpContext.GetItem<CookieConsentStatus>(ConsentCookieName);
192+
}
193+
194+
var cookie = context.HttpContext.Request.Cookies[ConsentCookieName];
195+
if (cookie != null && int.TryParse(cookie.Value, out var i))
196+
{
197+
return (CookieConsentStatus)i;
198+
}
199+
200+
return CookieConsentStatus.Unset;
192201
}
193202
}
194203
}

0 commit comments

Comments
 (0)