Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Log error on AJAX call for non-found function GUID #1427

Closed
wants to merge 3 commits into from

4 participants

Shadowfiend added some commits
@Shadowfiend Shadowfiend Add centralized handling for parameters not mapped to Lift functions.
We add a LiftRules entry, handleUnmappedParameter, that is a FactoryMaker that
vends a function to handle any parmaeter not mapped to a Lift function. By
default, the function checks if the parameter name starts with F, and logs a
warning if so. This is to do a quick, high-speed check as to whether or not the
parameter looks like a Lift function binding.
eac85f6
@Shadowfiend Shadowfiend Strip a no-longer-relevant warning about synchronization. fc7ae6f
@fmpwizard
Owner

:+1:

...kit/src/main/scala/net/liftweb/http/LiftSession.scala
@@ -744,8 +740,13 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
val toRun = {
// get all the commands, sorted by owner,
(state.uploadedFiles.map(_.name) ::: state.paramNames).distinct.
- flatMap {
- n => Box.legacyNullTest(nmessageCallback.get(n)).map(mcb => RunnerHolder(n, mcb, mcb.owner)).toList
+ flatMap { parameterName =>
+ val callback = Box.legacyNullTest(nmessageCallback.get(parameterName))
+
+ if (callback.isEmpty)
+ LiftRules.handleUnmappedParameter.vend(state, parameterName)
@farmdawgnation Collaborator

Indentation?

@Shadowfiend Owner

Weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@farmdawgnation
Collaborator

:+1:

@fmpwizard
Owner

on master now

@fmpwizard
Owner

and now on lift 3.0 too

@fmpwizard fmpwizard closed this
@fmpwizard fmpwizard deleted the log-unknown-guids branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2013
  1. @Shadowfiend

    Add centralized handling for parameters not mapped to Lift functions.

    Shadowfiend authored
    We add a LiftRules entry, handleUnmappedParameter, that is a FactoryMaker that
    vends a function to handle any parmaeter not mapped to a Lift function. By
    default, the function checks if the parameter name starts with F, and logs a
    warning if so. This is to do a quick, high-speed check as to whether or not the
    parameter looks like a Lift function binding.
  2. @Shadowfiend
Commits on Sep 9, 2013
  1. @Shadowfiend
This page is out of date. Refresh to see the latest.
View
15 web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala
@@ -493,6 +493,21 @@ class LiftRules() extends Factory with FormVendor with LazyLoggable {
@volatile var localizationLookupFailureNotice: Box[(String, Locale) => Unit] = Empty
/**
+ * When a parameter is received either via POST or GET and does not have a
+ * corresponding mapping on the server, the function provided by this
+ * FactoryMaker will be called with the req and parameter name.
+ *
+ * By default, if the parameter looks Lift-like (i.e., it starts with an F),
+ * then we log a warning with the given parameter name and URI.
+ */
+ val handleUnmappedParameter = new FactoryMaker[(Req,String)=>Unit](
+ () => { (req: Req, parameterName: String) =>
+ if (parameterName.startsWith("F"))
+ logger.warn("Unmapped Lift-like parameter seen in request [%s]: %s".format(req.uri, parameterName))
+ }
+ ) {}
+
+ /**
* Set to false if you want to have 404's handled the same way in dev and production mode
*/
@volatile var displayHelpfulSiteMapMessages_? = true
View
13 web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
@@ -574,10 +574,6 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
def ? = this.box openOr false
}
- /**
- * ****IMPORTANT**** when you access messageCallback, it *MUST*
- * be in a block that's synchronized on the owner LiftSession
- */
private val nmessageCallback: ConcurrentHashMap[String, S.AFuncHolder] = new ConcurrentHashMap
private val msgCallbackSync = new Object
@@ -744,8 +740,13 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
val toRun = {
// get all the commands, sorted by owner,
(state.uploadedFiles.map(_.name) ::: state.paramNames).distinct.
- flatMap {
- n => Box.legacyNullTest(nmessageCallback.get(n)).map(mcb => RunnerHolder(n, mcb, mcb.owner)).toList
+ flatMap { parameterName =>
+ val callback = Box.legacyNullTest(nmessageCallback.get(parameterName))
+
+ if (callback.isEmpty)
+ LiftRules.handleUnmappedParameter.vend(state, parameterName)
+
+ callback.map(funcHolder => RunnerHolder(parameterName, funcHolder, funcHolder.owner)).toList
}.
sortWith {
case (RunnerHolder(_, _, Full(a)), RunnerHolder(_, _, Full(b))) if a < b => true
Something went wrong with that request. Please try again.