In my Laravel 5.3 application I am using several Eloquent model events (mostly creating). Up until a week ago they were working fine but suddenly as of today I notice that none of them seem to be firing anymore.
Debugging through the framework shows that they are indeed all added to the Dispatcher::listeners array, but I can't find the code that should step through and actually run them. Placing die() commands in the event callbacks do nothing, suggesting they are not acutally firing, and nothing I try seems to get them working.
Here is an example of one of them (this one is on a trait, but I am using a mix of traits and direct model):
public static function bootUuidModel() {
// On create, generate and assign a UUID
static::creating(function (Model $model) {
$model->setAttribute(self::getUuidFieldKey(), Uuid::uuid4()->toString());
});
}
Anyone have any ideas as to why these are suddenly not running? I am using them across various models for various purposes and none of them seem to be running. Has anyone else using the framework experienced these problems as of late?
Thanks in advance
--UPDATE--
Okay so after some more investigation I've found that the problem is that the User object is for some reason booting BEFORE Laravel's DatabaseServiceProvider is booted. DatabaseServiceProvider::boot() for some reason is where the event dispatcher is statically assigned to Model. So any booting in the User object is not registering the events with the dispatcher because the dispatcher doesn't exist yet. I am not booting the User object myself, does anyone know why Laravel would be doing this?
Related
I don't know what happened, but all of a sudden the builder is not recognizing the methods. I checked, they are listed in schema.graphql.
I do
amplify push
but it doesn't work.
I think it started happening after I ran modelgen build.
If I look at the model in
app\src\main\java\com\amplifyframework\datastore\generated\model
the methods are there.
Todo todo = Todo.builder().name(0).build();
Cannot resolve method name in 'NameStep'
I ended up deleting the files in app\src\main\java, and running modelGen again, a couple times, and it started working again. I am not sure what happened, but this seemed to make it work.
This is my first attempt at working with Angular.js after using Backbone.js for some projects. I used Yeoman to get the initial angular scaffolding setup as well as to manage various dependencies etc.
The first issue I've run into is with the angular $resource service I setup to hit an external API which returns a simple array of names. In using the Chrome web inspector I see that the data is returned as expected but never renders. I suspect this is due to the call by asynchronous and when the page renders there is no data to show. Shortly after the page renders the data is returned from the API but the page never re-renders again.
The Angular docs state pretty clearly in the tutorial that this should happen automagically via the angular data binding but so far it's never worked for me.
I put the code I'm experimenting with now up in a repo on GitHub at https://github.com/chad-skidmore/angular-test
I've not found any documented issues so far regarding this issue after spending the last couple days hacking around to try and get it to work. If I pass an array to the controller it works fine of course which is one reason I think that there is something hosed in the data binding for async external resource calls.
Any pointers or help would be appreciated.
You can also get to the same code on plnkr: http://plnkr.co/edit/BAHhsT2l1HKnpjiKLZMK
Thanks,
chad
I'm trying to publish a page during Workflow. There are two environment that we are publishing to during workflow process: one to test and one to live. During the first automatic activity we are publishing to test and during that process the Components on the Pages don't need to be approved. We got that to work.
However when we approve the Page and the Page is being published to live, we need to make sure that we only publish approved Components (i.e. major versions).
In my code I'm using the Page.Publish method, but with that I can't specify that it should only publish approved items.
The publish method accepts an argument called activateWorkflow. When set to True it publishes both approved and unapproved items; but when set to False it gets added to the queue and we get a success message, but nothing gets published.
Anyone have any ideas how I can fix this, using the publishing method and without manually checking?
Thanks.
I ran into a similar issue when going through Component Workflow and having to publish static pages (no dynamic component presentations).
When publishing to test, as you mentioned, simply do activateWorkflow=true. For your Live environment you need to kick off publishing after workflow completes. I've resolved the issue via the event system for this. Here an article that discusses this in more detail that may help you:
http://www.tridiondeveloper.com/autopublishing-on-workflow-finish
It is not clear where you are performing the activities, are you doing this from within your workflow activities in Visio?
Publishing will always only publish items that are either in the approved status for that target and items that have finished workflow (major versions).
All that said, I believethe reason you are getting empty PublishTransacctions is because you are calling the Publish() method on new items before you finish the page workflow activity (which means your new item is still in workflow, so the false value means there is nothing to publish which is not in workflow). Try calling FinishActivity() before the Publish() method is called.
Perhaps you could post your code from the final step so we can see exactly what you are doing.
I have a problem with an MVC 3 application that is using the new .NET 4 System.Runtime.Caching MemoryCache. I notice that after a seemingly unpredictable time, it stops caching stuff, and acts like it's empty. Consider this bit of code that I took straight from a test View in ASP.NET MVC:
MemoryCache.Default.Set("myname","fred", new CacheItemPolicy() { SlidingExpiration = new TimeSpan(0,5,0) });
Response.Write(MemoryCache.Default["myname"]);
When it's working, predictably "fred" gets printed. However, when the problem starts to occur, despite the Set(), the value of MemoryCache.Default["myname"] is null. I can prove this by setting a breakpoint on the Response.Write() line and directly setting and reading from the cache using the Immediate Window - It just won't set it and stays null! The only way to get it working again then is to cause an AppDomain recycle.
Intriguingly I can provoke the problem into occurring when the app is working normally by breaking on the Response.Write() line and running MemoryCache.Default.Dispose(). After that, MemoryCache.Default is not null itself (why is this?), but won't save anything set on it. It doesn't cause any errors, but just won't save anything.
Can anybody verify this and explain? As I believe I have discovered, when the app stops working on its own, something is Disposing MemoryCache.Default, but it's not me!
UPDATE
Well, I'm sick of this prob now! CLRProfiler doesn't seem to work with MVC 3. SciTech's CLR tool was good - so was RedGate ANTS. But all they told me was that the MemoryCache object is being disposed by something! I also proved (via a timestamp print) that a PartialView on my page that should be cached (specified by OutputCacheAttribute) stops being cached after a few minutes - it starts refreshing with every call to the page. Just to clarify the environment, I am running directly on the IIS 7.5 server on my development workstation running Win 7 Ultimate. The memory tools mentioned above suggest I am only using about 9mb of memory in terms of objects in play.
In desperation I have changed my caching code to first search for an ambient HttpContext to hook onto and use its Caching functionality, if one's available. Early tests show this is reliable, but it feels like a nasty hack.
Am getting the feeling that MemoryCache and OutputCache aren't warranted to work with MVC 3...
So, here's some news. We looked into this and YES, this is a bug in .NET 4.
The good news is that it was fixed in .NET 4.5, so if you can, update your installation to .NET 4.5 and you're solid.
The other good news it that this fix has been back-ported to .NET 4 and will be available as a QFE (Quick Fix...a one off fix you'll apply) #578315. It was backported/fixed just days ago and it should be out ASAP. I'll try to get an exact date, but it's soon.
The other other good news is that there's a workaround for this on .NET 4 before the QFE. The workaround is weird, but it could unblock you.
using (ExecutionContext.SuppressFlow()) {
// Create memory cache instance under disabled execution context flow
return new YourCacheThing.GeneralMemoryCache(…);
}
Hope this helps.
UPDATE: The Hotfix is http://support.microsoft.com/kb/2828843 and you can request it here: https://support.microsoft.com/contactus/emailcontact.aspx?scid=sw;%5BLN%5D;1422
We have the same problem. I confirm that after some period of time cache became disposed. It's private field _disposed became 1. I am sure that I don't have call to cache.Dispose in my code. But when I looked at code of MemoryCache with Reflector I saw, that in constructor it subscribes on two events
domain.DomainUnload += eventHandler;
domain.UnhandledException += exceptionEventHandler;
private void OnAppDomainUnload(object unusedObject, EventArgs unusedEventArgs)
{
this.Dispose();
}
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs eventArgs)
{
if (!eventArgs.IsTerminating)
return;
this.Dispose();
}
Both of these event handlers have call to Dispose. May be after some domain recycling in IIS it causes domain unload, but keeps cache in memory(i'am not shure if it is possible).
I have been experiencing the exact same symptoms. I have finally resulted to using the System.Web.Cache class instead and hooking into HttpContext.Cache. It has been working perfectly for the last 3 days..
See also these links related to the same problem.
MemoryCache gets disposed after PollingInterval when used in WebApp in Integrated Pipeline mode
http://connect.microsoft.com/VisualStudio/feedback/details/764911/memorycache-gets-disposed-after-pollinginterval-when-used-in-webapp-in-integrated-pipeline-mode
MemoryCache get in Disposed state Magically
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1233ffb3-6480-431b-94ca-1190f96cf5f6
The MemoryCache will automatically evict items if it hits it's memory limit. This could be happening in your case, do you have a lot of items in the cache?
You can control the limits with configuration. By default it optimises based on the available memory.
Certainly calling Dispose will stop the MemoryCache instance working as it will clean up all unmanaged resources ready for disposal. You should only call Dispose if you do not intend to use the MemoryCache any more. I don't think this is necessary the problem in your case, other than when you call it.
We are getting intermittent problems on a production server that we cannot recreate.
There are two very strange things about the issue. Firstly it's a method not found error on the constructor (ctor) for an exception handling helper class and secondly we have custom errors switched on for remote users and this property is being ignored.
The detail of the error is:
Server Error in '/MyWebsite' Application.
Method not found: 'Void MyExceptionHelperClass..ctor (System.Exception)'.
...
Exception Details: System.MissingMethodException: Method not found: 'Void MyExceptionHelperClass..ctor (System.Exception)'.
...
The stack trace is pretty unhelpful.
My thoughts are that there may be an out-of-memory error or something like that that is killing the page. When the exception handling code kicks in it tries to create an exception object which fails for the same reason giving this error.
However this is wild speculation. We are waiting for the event logs to see whether anything is amiss with the server but in the meantime does anyone have any thoughts or suggestions?
UPDATE:
It has proven difficult to get information out of the team responsible for the production servers but I have managed to find out that as far as load balancing is concerned, this site is currently only running on one server (this can be made to switch over onto another if necessary). Given that this is an intermittent problem and there is only one server involved, then I find it difficult to believe that this could be an assembly issue. Surely if it was then the problem would occur every time?
If you see this error happening on a site that has custom errors turned on, then the error is happening in the custom error handling routine itself.
From the look of the .NET error message it appears that your routine is expecting a constructor that accepts an exception by reference - your comment above shows a constructor that accepts by value.
Check carefully that there isn't a stale version of an assembly in your system somewhere. These can lurk in the Temporary ASP.NET Files folder; you'll need to do an "iisreset /stop" before you can clear them out.
In that regard it's always a good idea to make sure that AssemblyInfo.cs is set up to automatically stamp version numbers in some way. We have our version numbers tied to our source code repository system and CI build box so we can tell exactly what was in what assembly really easily.
I would use elmah: http://code.google.com/p/elmah/ to hopefully give you a bit more insight into the issue. It is free and can be used on an existing site without any recompilation. Try it - and post back if the issue is still happening.
As others have also mentioned, I would suspect that your site is somehow using an out of date version of an assembly. Something you could try doing is a full Precompile of your site before deploying to your production server. This ensures that ASP .Net doesn't dynamically compile the site on the fly, and therefore should mean that it's using completely up to date code throughout.
Do you have a no parameter public constructor defined for MyExceptionHelperClass in your code? Or is the class meant to only have static methods, in which case it should be a static class.
public class MyExceptionHelperClass()
{
public MyExceptionHelperClass() { }
}
Unfortunately, this may be one of those cases where the error message is of little to no value. In my experience, this general class of exception may be the result of either a configuration issue or bad logic aroung threading/app domains. For example, I have seen similar issues upon attempting to load the same assembly into an app domain more than once.
You mention that this is difficult to reproduce. If it's only happening on one server in the production farm it's more likely to be a config issue (with that machine). If it's happening on more than one server than it could be either config or threading.
It might be worth spending some time looking at the larger code base around the areas mentioned above. The root cause may not be in this class. Good luck!
I think it's a Framework issue with keeping compiled versions consistency. It's common to see same sort of errors while updating site sources repeatedly. Just try something like
net stop iisadmin /y && del /q /f /s "%systemroot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\*.*" && iisreset
I encountered this exception today on a webforms page. I found a solution, but I'm not sure why it worked.
Nest the code behind in a 'Namespace [YourNamespace]' tag.
Add the namespace to the html Page tag's Inherits property in the aspx page 'Inherits="PathStart.YourNameSpace.ClassName"'.
Rebuild
Navigate to the page again and you should not encounter the exception.
After following the steps above I reverted the changes and did not re-encounter the exception.