kipusoep / UrlTracker

The Url Tracker for Umbraco
MIT License
54 stars 61 forks source link

NullReferenceException with 7.3 Beta 3 and Multiple root nodes #90

Closed JBoye closed 8 years ago

JBoye commented 9 years ago

I get the following exception on all 404 pages. It can be reproduced by installing a clean 7.3 Beta 3, and create multiple root nodes

[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.Routing.DefaultUrlProvider.GetUrl(UmbracoContext umbracoContext, Int32 id, Uri current, UrlProviderMode mode) +243
Umbraco.Web.Routing.<>c__DisplayClass3.<GetUrl>b__0(IUrlProvider provider) +49
System.Linq.WhereSelectArrayIterator`2.MoveNext() +110
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +214
Umbraco.Web.Routing.UrlProvider.GetUrl(Int32 id, Uri current, UrlProviderMode mode) +235
InfoCaster.Umbraco.UrlTracker.Modules.UrlTrackerModule.UrlTrackerDo(String callingEventName, Boolean ignoreHttpStatusCode) in d:\kipusoep\Documents\GitHub\UrlTracker\Modules\UrlTrackerModule.cs:178
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +160
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
JBoye commented 9 years ago

Complete project: http://upload.lindberg.pro/9wqpn/umbracocms730-beta3.zip - backoffice user: user: admin pass: test

kipusoep commented 9 years ago

Thanks, I'll look into this, I think tomorrow :-)

nul800sebastiaan commented 9 years ago

I've had a look at it and the null reference is umbracoContext here, even though you're "ensuring" the context (which made Shannon nervous when I asked him about it). But it's out of my league to debug fully.

kipusoep commented 9 years ago

Hmm, @nul800sebastiaan you looking into this issue, does that mean you're having the same issue on our umbraco?

nul800sebastiaan commented 9 years ago

Nope, I only have one domain set on Our. Just looking to see what we broke in Umbraco (if anything).

kipusoep commented 9 years ago

So it seems UmbracoContext.Application is null, which is weird because ApplicationContext.Current is set and usable. Seems like a breaking change in Umbraco and maybe even a bug? What do you think @nul800sebastiaan ?

JBoye commented 9 years ago

Just to confirm, @nul800sebastiaan's PR fixes the issue for me

shearer3000 commented 9 years ago

hi - will this be released soon? :D

kipusoep commented 9 years ago

I'll test again Friday and hopefully release an update! Apologies for the delay!

shearer3000 commented 9 years ago

no worries. thanks!

shearer3000 commented 8 years ago

hi - is there any scheduled release in mind yet? thanks

kipusoep commented 8 years ago

Yes, I fixed it today and will release an update tomorrow.

kipusoep commented 8 years ago

Just released 3.10-rc. I need some help testing it before marking it as stable. It's available on NuGet: https://www.nuget.org/packages/UrlTracker/3.10.0-rc

Please help me test this :-)

engern commented 8 years ago

Just tested it on my 7.3.0 and seems to work just fine. I have created manually and from 404 view. Both 301 and 302. Regex is like Greek to me, so I have not tested that. Force redirect works. Querystring works. Great job :+1:

kipusoep commented 8 years ago

Thanks @engern for testing and creating an account just for this comment ;-)

nul800sebastiaan commented 8 years ago

Haven't had time to test, just one scenario I just thought of: does it handle .html? So say your old said had some html files you want to redirect, does that work properly with this version?

kipusoep commented 8 years ago

Dammit! It doesn't :-( Now I remember why I used an HttpModule... So now what?

Ps. Thanks for the heads-up, didn't think about that scenario.

nul800sebastiaan commented 8 years ago

Yeah, I just realized that contentfinders don't handle "static" files. I'll have a chat with Shannon to see what else we can do.

kipusoep commented 8 years ago

Please do, I'm out of options.

ZNS commented 8 years ago

I'm looking into this issue also. In 7.3.1 UmbracoContext.Security is still disposed on EndRequest. This causes UmbracoContext.Current.UrlProvider.GetUrl() to throw an exception. The problem is that it doesn't seem possible to catch certain requests (mainly for static files) on any other event than EndRequest. At least not after that Umbraco has handled the request. I've tried PostReleaseRequestState and UpdateRequestCache and neither fires.

nul800sebastiaan commented 8 years ago

So, you were right @kipusoep - the response.End() in PublishedContentNotFoundHandler causes the PostRequestHandlerExecute event to not be fired. We'll remove it for 7.3.2.

Question is though.. how were you ever handling .html (etc.) files before? We don't create an Umbraco context for static files so I'm not sure how that worked before.

So: for non-static files you can use PostRequestHandlerExecute in 7.3.2 and the GetUrl call should succeed. For static files you'd still subscribe to the EndRequest event and do what you did before I guess? I just don't know how you managed to get a Url from this before.

kipusoep commented 8 years ago

@nul800sebastiaan I know a few things about HttpModules and Response.End() etc. ;-) An HttpModule gets executed for every request, also for .html requests, so that's how I handle them, easy as that :-) Sorry didn't read that correctly. I don't know why Umbraco stuff is working for .html requests, it just does ;-)

So back to an HttpModule it is, glad this is being fixed in 7.3.2!

nul800sebastiaan commented 8 years ago

You can give it a go with the latest nightly (build 110): http://nightly.umbraco.org/?container=umbraco-730

denisedelbando commented 8 years ago

kinda need this fix or we cant upgrade to 7.3.1. Is there any update to this?

kipusoep commented 8 years ago

@avatart0ph You can use the RC which works with 7.3.0 and 7.3.1. The only issue is with non-asp.net URL's, like .html and .php. For 7.3.2 I'll have to create a new release.

akeilox commented 8 years ago

@kipusoep can I clarify, for users on 7.1 if I download the latest source and compile, the non-asp.net URLs will be working? I normally download the source and edit the info page/tabs (with text and internal links that editors can read further) instead of installing from the package. Would appreciate if you can clarify.

kipusoep commented 8 years ago

For 7.1 you don't need the RC, just go for 3.9 :-)

akeilox commented 8 years ago

Thanks!

denisedelbando commented 8 years ago

@kipusoep thank you. unfortunately, we will have to wait for 7.3.2 >_< already skipped 7.3.0 and now this version cause we need your plugin to work.

nul800sebastiaan commented 8 years ago

We're not perfect, sometimes we accidentally break things (like this) and then we try hard to come up with a solution (like for this problem). :-)

kipusoep commented 8 years ago

It's hard, if not impossible, to think of all possible consequences with every code change. So cut them some slack please :-)

denisedelbando commented 8 years ago

@nul800sebastiaan @kipusoep I apologize. no one is perfect. its just hard being the 'man in the middle' and i cant control some things. i love umbraco and have just started contributing to other projects (if i have tested it in a working environment and no issues from client for months). I guess umbraco just needs some sort of control to the plugins?

kipusoep commented 8 years ago

We're all part of this community and everybody needs to help by fixing 3rd party plug-in issues and umbraco issues, that's the great thing about open-source software :-) As I said; you can use the UrlTracker RC for Umbraco 7.3.0 and 7.3.1, automatic redirects will still work, just not .html/.php requests. But maybe you do have redirects for those extensions?

denisedelbando commented 8 years ago

@kipusoep yeah i do. php and html. lol.:)

kipusoep commented 8 years ago

Ah, I'm sorry about that. Then you'll just have to wait for 7.3.2, can't take long I guess. Do you have a planned release date @nul800sebastiaan? So I can have a working and tested release ready before the release?

kipusoep commented 8 years ago

Ok so it seems 7.3.2 is release just now. I'm sorry, but I don't have an update UrlTracker release yet. Hopefully tomorrow.

nul800sebastiaan commented 8 years ago

Ah sorry, forgot to update this ! We weren't quite sure if we would be able to release this week :-)

kipusoep commented 8 years ago

I just tested the new PostRequestHandlerExecute with Umbraco 7.3.2, but it's not getting executed when I request "/test.html". EndRequest is getting executed though. I'm just not sure why this is happening. :-(

kipusoep commented 8 years ago

Fuuuuuuuu: Occurs when the ASP.NET event handler (for example, a page or an XML Web service) finishes execution.

nul800sebastiaan commented 8 years ago

Yeps, that's what I was trying to say here, you'll need to use both:

So: for non-static files you can use PostRequestHandlerExecute in 7.3.2 and the GetUrl call should succeed. For static files you'd still subscribe to the EndRequest event and do what you did before I guess? I just don't know how you managed to get a Url from this before.

kipusoep commented 8 years ago

It seems I don't have to change a thing; just using EndRequest works again like it used to, so 3.9 will just work :-)

nul800sebastiaan commented 8 years ago

Ah yes.. I think that should work! :-)

JBoye commented 8 years ago

I tried to upgrade Umbraco to 7.3.2 and downgraded Url tracker to 3.9, but now I'm getting these again on a 404 request:

[NullReferenceException: Object reference not set to an instance of an object.] Umbraco.Web.Routing.DefaultUrlProvider.GetUrl(UmbracoContext umbracoContext, Int32 id, Uri current, UrlProviderMode mode) +262 Umbraco.Web.Routing.<>cDisplayClass3.b0(IUrlProvider provider) +47 System.Linq.WhereSelectArrayIterator2.MoveNext() +109 System.Linq.Enumerable.FirstOrDefault(IEnumerable1 source, Func`2 predicate) +121 Umbraco.Web.Routing.UrlProvider.GetUrl(Int32 id, Uri current, UrlProviderMode mode) +259 InfoCaster.Umbraco.UrlTracker.Modules.UrlTrackerModule.UrlTrackerDo(String callingEventName, Boolean ignoreHttpStatusCode) in d:\kipusoep\Documents\GitHub\UrlTracker\Modules\UrlTrackerModule.cs:178 InfoCaster.Umbraco.UrlTracker.Modules.UrlTrackerModule.context_EndRequest(Object sender, EventArgs e) in d:\kipusoep\Documents\GitHub\UrlTracker\Modules\UrlTrackerModule.cs:81 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +97

JBoye commented 8 years ago

Reproduced in 7.3.2 + Url Tracker 3.9:

http://upload.lindberg.pro/8g7il/732.zip user: admin pass: testtest

kipusoep commented 8 years ago

Yeah me too, I thought it worked but it doesn't :-( So the question is; what changed in Umbraco 7.3 that kills the UrlTracker's ability to get a Node's url in the EndRequest handler?

danimalx commented 8 years ago

We are getting this error under these circumstances in a load balanced (new method) environment on 7.3.3:

Go to a non-existant page which should give a nice 404 page on a sub directory on the LB domain.

If the page is accessed directly on each of the web servers it's fine. If it's accessed in the root it's fine. e.g.

http://www.loadbalanced.com/xxx/page-does-not-exist - 404 page does not work http://www.loadbalanced.com/page-does-not-exist - 404 page works

http://www.web1.com/xxx/page-does-not-exist - 404 page works http://www.web2.com/xxx/page-does-not-exist - 404 page works http://www.web1.com/xxx/page-does-not-exist - 404 page works http://www.web2.com/xxx/page-does-not-exist - 404 page works

shearer3000 commented 8 years ago

hi - what is the current status of this ticket? The main umbraco use-case of redirecting an old node url to its new url doesn't work for me on 7.3.2 and urlTracker 3.9

shearer3000 commented 8 years ago

Is there any more info and/or testing I can help with?

kipusoep commented 8 years ago

I don't know what to do. @nul800sebastiaan said to me on Twitter:

Haven't had any time mate, sorry! @Shazwazza is on holiday. I'll look when I get a chance.

danimalx commented 8 years ago

I appreciate you are busy but because your package is so good it's also essential for anyone wanting to upgrade to 7.3 - it really should be part of the core IMHO. I think we'd all be very happy if it was made compatible with 7.3