U4-2733 - call to umbraco.library:Request broken?

Created by Jan Skovgaard 28 Aug 2013, 09:40:03 Updated by Sebastiaan Janssen 07 Oct 2013, 06:19:37

Hi there

It seems that when using umbraco.library:Request() the passed parameters value is never fetched? Tink it might also be an issue with RequestForm and RequestQuerystring.

We've seen this in Umbraco 6.1.4, don't know if it's also the case in 6.0.x

Comments

Sebastiaan Janssen 28 Aug 2013, 15:05:16

Got an example XSLT?

If I put this XSLT macro on the homepage and go to localhost:1234/?hello=world then it shows "world".

]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

<xsl:template match="/">
    <xsl:value-of select="umbraco.library:Request('hello')" />
</xsl:template>

</xsl:stylesheet>

Same result if I change it to:

<xsl:value-of select="umbraco.library:RequestQueryString('hello')" />

Try to set this in umbracoSettings.config and recycle the app pool, should give you the real error if something goes wrong in your macro. throw


Thor Madsen-Holm 05 Sep 2013, 14:47:22

Hi Sebastian,

I've encountered this issue aswell, it happens when I use <xsl:value-of select="umbraco.library:Request('hello')" /> in a macro that is inserted in a RTE field.

It works fine when the macro is inserted in a masterpage/View

/Thor


Sebastiaan Janssen 05 Sep 2013, 15:06:37

@Thor: I've just tested that too in 6.1.5 and again, I can't reproduce it.. works just fine here (using the same macro as above). So again, if you can give me an error (preferable a stack trace) then we can look at it.


Thor Madsen-Holm 05 Sep 2013, 15:36:43

I've just upgradeded to 6.1.5 and it still doesn't work.

I tried adding throw in umbracoSettings, but no errors are shown (I have recycled the app pool etc). I don't get any stack trace when using umbDebugShowTrace, but thats probably because im using Mvc. I tried getting some debug information by adding umbDebug to the querystring, however that only shows which macros where loaded.

I tried looking in the UmbracoTraceLog file, but could'nt find anything that seemed related to it.

Is there anything else I can do to help debug ?

/Thor


Sebastiaan Janssen 06 Sep 2013, 12:53:58

Still no luck, I've tried it in MVC mode too, works fine. Maybe it would help if you post the exact XSLT file that you're using.

Make sure umbracoDebugMode is set to true and too, to get errors. You should at least see errors like this in the log: 2013-09-06 14:52:58,797 [6] WARN umbraco.macro


Thor Madsen-Holm 08 Sep 2013, 12:02:10

Just checked to make sure umbracoDebugMode and compilation was set to true, both are. I searched through the log for "umbraco.macro" but couldn't find anything.

Here is the exact xslt file, it worked as intended before i upgraded to v6:

]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.email="urn:ucomponents.email" xmlns:ucomponents.io="urn:ucomponents.io" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.random="urn:ucomponents.random" xmlns:ucomponents.request="urn:ucomponents.request" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ucomponents.cms ucomponents.dates ucomponents.email ucomponents.io ucomponents.media ucomponents.members ucomponents.nodes ucomponents.random ucomponents.request ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml ">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>

<xsl:template match="/">
    <xsl:if test="umbraco.library:Request('contact-navn')">
        <xsl:call-template name="send-mail" />
    </xsl:if>
    <xsl:call-template name="contact-form" />
</xsl:template>

<xsl:template name="send-mail">
    <xsl:variable name="bot" select="umbraco.library:Request('erdusaadanen')" />

    <xsl:if test="not(string-length($bot) &gt; 0)">
        <xsl:variable name="name" select="umbraco.library:Request('contact-navn')" />
        <xsl:variable name="email" select="umbraco.library:Request('contact-email')" />
        <xsl:variable name="subject" select="umbraco.library:Request('contact-emne')" />
        <xsl:variable name="message" select="umbraco.library:Request('contact-besked')" />

        <xsl:variable name="from" select="'frommail@mail.com'" />
        <xsl:variable name="to" select="'tomail@mail.com'" />
        <xsl:variable name="emailSubject" select="'subject'" />
        <xsl:variable name="emailBody">
            <xsl:if test="$name != ''">
                <![CDATA[Navn: ]]>
                <xsl:value-of select="$name"/>
                <![CDATA[<br />]]>
            </xsl:if>

            <xsl:if test="$email != ''">
                <![CDATA[E-mail adresse: ]]>
                <xsl:value-of select="$email"/>
                <![CDATA[<br />]]>
            </xsl:if>

            <xsl:if test="$subject != ''">
                <![CDATA[Emne: ]]>
                <xsl:value-of select="$subject"/>
                <![CDATA[<br />
                ]]>
            </xsl:if>

            <xsl:if test="$message != ''">
                <![CDATA[Besked: ]]>
                <xsl:value-of select="$message"/>
            </xsl:if>

        </xsl:variable>

        <xsl:variable name="sendMail" select="umbraco.library:SendMail($from, $to, $emailSubject, $emailBody, true())" />            
    </xsl:if>
</xsl:template>

<xsl:template name="contact-form">
    <form id="contact-form" class="contact-form" name="contact-form" action="{umbraco.library:NiceUrl($currentPage/@id)}" method="get">
        <fieldset>
            <input type="hidden" name="erdusaadanen" value=""/>

            <div>                    
                <input id="contact-navn" class="required" name="contact-navn" type="text" value="">
                    <xsl:attribute name="autofocus"></xsl:attribute>
                </input>
            </div>

            <div>                    
                <input id="contact-email" class="required" name="contact-email" type="text" value="" />
            </div>

            <div>                    
                <input id="contact-emne" name="contact-emne" type="text" value="" />
            </div>

            <div>                    
                <textarea id="contact-besked" class="required" name="contact-besked" type="text" value="">
                    <xsl:text> </xsl:text>
                </textarea>
            </div>

            <input type="submit" value="Send besked"/>

        </fieldset>
    </form>
</xsl:template>

</xsl:stylesheet>


Sebastiaan Janssen 08 Sep 2013, 16:09:47

Okay, I tried this and it seems to work just fine. I'm not sure if you're ignoring the validations in the XSLT editor but:

<xsl:if test="$name != ">

Should be <xsl:if test="$name != ''">

If I change that one (and email, subject and message) then it works just fine in both webforms and mvc mode.

Note: I don't have the same xml namespaces imported, try replacing them with the following, these are the default ones if you don't have packages installed:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:Examine="urn:Examine" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Examine ">


Thor Madsen-Holm 12 Sep 2013, 11:33:10

Hi Sebastian,

Sorry for that late reply.

In the original file it actually is typed like this: $name != '' - Seems the editor stripped som characters when I pasted in the contents of the xslt file - so that is definately not the problem.

I tried replacing the namespaces with the default ones, however that did not fix the problem either.

The site runs on sqlce, so I could package up the entire site and send it to you for debugging if that would help?

/Thor


Sebastiaan Janssen 12 Sep 2013, 11:48:03

Sure!


Sebastiaan Janssen 13 Sep 2013, 13:05:30

Okay so you're doing this to render the content of the pages in question:

<xsl:value-of select="umbraco.library:Item($currentPage/@id,'content')" />

That eventually ends up in Umbraco.Web.UmbracoHelper.RenderMacro On line 194 this is doing:

_umbracoContext.HttpContext.Server.Execute(containerPage, output, false);

That last parameter (false) is called "preserveForm". If I change that to true then your XSLT works again.

I'll assign it to Shannon to see why we don't pass the request values through there.


Shannon Deminick 07 Oct 2013, 01:24:41

Setting to true should be no problem, I don't have time today to make the change so will leave it to you if you have time, otherwise will change tomorrow.


Sebastiaan Janssen 07 Oct 2013, 06:19:28

Fixed in rev a90f32035dad342e56b1109e31a7141987e4a6e8


Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.3, 6.1.4

Due in version: 6.2.0

Sprint:

Story Points:

Cycle: