Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Invalid model/method definition, expecting "model/class::method", got "" instead" when using Aoe_Scheduler and Xtento_OrderExport #501

Closed
mzeis opened this issue Oct 4, 2017 · 19 comments
Assignees
Labels

Comments

@mzeis
Copy link

mzeis commented Oct 4, 2017

Mailchimp 1.1.8 causes Xtento Order Export cronjobs to fail when

  • using Aoe_Scheduler
  • and the mailchimp jobs run in the same cron execution as the order export extension
  • and the mailchimp job runs before the order export (the other way around works fine).

I didn't test with 1.1.9 yet. It used to work with the old MageMonkey extension. I assume only Xtento is affected because they create the cronjob config XML dynamically.

Pre-conditions for re-production

Extensions

  • Aoe_Scheduler 1.5.0
  • Ebizmarts_MailChimp 1.1.8
  • Xtento_OrderExport 1.9.8

Cronjob schedule

  • Have mailchimp and order export jobs scheduled at the same time

Re-production

If Magento chooses to run the order export job first, everything will work fine. If mailchimp jobs are executed first, the order export job will fail with this message:

Mage_Core_Exception: Invalid model/method definition, expecting "model/class::method", got "" instead. in /path/to/magento/app/Mage.php:595
Stack trace:
#0 /path/to/magento/app/code/community/Aoe/Scheduler/Helper/Data.php(316): Mage::throwException('Invalid model/m...')
#1 /path/to/magento/app/code/community/Aoe/Scheduler/Model/Job.php(143): Aoe_Scheduler_Helper_Data->getCallBack('')
#2 /path/to/magento/app/code/community/Aoe/Scheduler/Model/Schedule.php(209): Aoe_Scheduler_Model_Job->getCallback()
#3 /path/to/magento/app/code/community/Aoe/Scheduler/Model/Schedule.php(605): Aoe_Scheduler_Model_Schedule->runNow(true)
#4 /path/to/magento/app/code/community/Aoe/Scheduler/Model/Observer.php(39): Aoe_Scheduler_Model_Schedule->process()
#5 /path/to/magento/app/code/local/Xtento/OrderExport/Model/Observer/Cron/Config.php(24): Aoe_Scheduler_Model_Observer->dispatch(Object(Varien_Event_Observer))
#6 /path/to/magento/app/code/local/Mage/Core/Model/App.php(1335): Xtento_OrderExport_Model_Observer_Cron_Config->addCronjobsToConfig(Object(Varien_Event_Observer))
#7 /path/to/magento/app/code/local/Mage/Core/Model/App.php(1308): Mage_Core_Model_App->_callObserverMethod(Object(Xtento_OrderExport_Model_Observer_Cron_Config), 'addCronjobsToCo...', Object(Varien_Event_Observer))
#8 /path/to/magento/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#9 /path/to/magento/shell/scheduler.php(518): Mage::dispatchEvent('default', Array)
#10 /path/to/magento/shell/scheduler.php(37): Aoe_Scheduler_Shell_Scheduler->cronAction()
#11 /path/to/magento/shell/scheduler.php(545): Aoe_Scheduler_Shell_Scheduler->run()
#12 {main}

While I understand that other 3rd party extensions are involved I report this here because it used to work with the MageMonkey extension and it's reproducible for us that the installation of the Mailchimp extension breaks this functionality.

@Santiagoebizmarts
Copy link
Contributor

Hello @mzeis

There is nothing relating MailChimp For Magento with this error.
Knowing how they handle the mentioned cron job would be great to see the cause of this problem.
There seems to be an error in a model declaration or a conflict with it, I suggest you to try with version 1.1.9.1 just in case the problem is with version 1.1.8 only.
What version of Magento are you using?

Regards

@mzeis
Copy link
Author

mzeis commented Oct 6, 2017

@Santiagoebizmarts EE 1.14.2.

@Santiagoebizmarts
Copy link
Contributor

@mzeis

Okay, how did it go to with version 1.1.9.1?

@mzeis
Copy link
Author

mzeis commented Oct 6, 2017

@Santiagoebizmarts I can try and ask the merchant if we can test this - sorry can't promise it.

FYI: using the cron group feature to separate the mailchimp cronjobs from the other jobs solves the problem.

@Santiagoebizmarts
Copy link
Contributor

Thanks we will review this.

Regards.

@ikk0
Copy link

ikk0 commented Oct 7, 2017

@mzeis: Hi, Sebastian @ XTENTO here. Thank you for detecting the connection between Aoe Scheduler, XTENTO Order Export and MailChimp. We've been having this issue for quite a long time but were never really able to figure out what caused this. We always thought it's some kind of sophisticated bug in AOE Scheduler, as it doesn't seem to happen when AOE Scheduler is not installed, but now that I think I know what's going on, I think that AOE Scheduler is not the actual problem; when AOE Scheduler is not installed, nobody notices this error as no exception is thrown with Magentos internal cron module.

Our Magento 1 import/export modules listen for the "default" event in the <crontab> area that is dispatched right before the cronjob runs. At this time, our modules (which can have multiple import/export profiles with different cron schedules that are configurable from the Magento backend) inject their cronjobs into the Magento system configuration via:

Mage::getConfig()->extend($cronConfig, true);

Now, having checked the code of the Mailchimp module, the problem is probably this:

https://github.com/mailchimp/mc-magento/blob/develop/app/code/community/Ebizmarts/MailChimp/Helper/Data.php#L1012

The call on line 1012 to

Mage::getConfig()->cleanCache();

in the Mailchimp module causes the Magento configuration to be re-initialized:

public function cleanCache() { return $this->reinit(); }

At that point, the cron configuration we injected dynamically is "gone", and even though AOE Scheduler has an entry in the cron_schedule table and knows it is supposed to execute our cronjob, it can't find it anymore as it's not in the configuration as it has been "reset" by Mailchimp.

This would make sense per Matthias description, as the error would only occur if the Mailchimp cron executes before our cron; not the other way round.

So, @Santiagoebizmarts - can you please look into removing the cleanCache call? And check if cleanCache is called somewhere else in your codebase during cron execution?

@Mandrino
Copy link

Mandrino commented Oct 7, 2017

Hello,
I just wanted to throw in, that we are using Magento OS 1.9.3.6 and MailChimp for Magento 1.1.9.1 and Xtento Product Export Feed 1.9.7, which also uses Cronjobs. We have no Problems.
Bye

@mzeis
Copy link
Author

mzeis commented Oct 7, 2017

@Mandrino In my experience, with OrderExport this only happens if both jobs are scheduled for the same minute, are processed in the same process (= group) and if the MailChimp job is executed before the Xtento job. Is this the case for you too?

@Mandrino
Copy link

Mandrino commented Oct 7, 2017

@mzeis
MailChimp Tasks are scheduled every 5 minutes.
XTENTO cron test ist also scheduled every 5 minutes.
2-times a day, our cronjobs are scheduled to the full hour (12/24).

However, at the Moment, I am nor sute which one is executed first when the server hits cron.sh . I'll have to surveil that.

@Santiagoebizmarts
Copy link
Contributor

Hello @ikk0

Thank you very much for this great feedback. Unfortunately there are some changes in the core_config_data table that require the cleanCache command to be executed in order for the changes to be applied. We will try to find a workaround but in the meantime I would suggest to avoid running xtento cron job until the initial sync finishes. After this the cleanCache command will not be executed.

Regards.

@JamesAllwood
Copy link

Hi all. Just to add to this, after @ikk0 pointed me in the right direction of this, disabling AOE scheduler has corrected the exact same issue as described by @mzeis.

For me, the issue started at the exact same time I switched from Magemonkey to MC for Magento.

@m-overlund
Copy link
Contributor

m-overlund commented Jan 10, 2018

Couldn't this be resolved by only flushing the affected cache types
Mage::app()->getCacheInstance()->cleanType()
Or
Mage::app()->getCacheInstance()->flush();

Or disabling cache first, then make chances, and then enable + save cache once again?
https://gist.github.com/markoshust/c5480b7b87c2cceae0bd

@m-overlund
Copy link
Contributor

We still have this issue.
Everytime MailChimp cron tasks runs at the same time as fx aforementioned Xtento modules tasks, the job breaks. So we have to schedule MailChimp to only run every half hour

@m-overlund
Copy link
Contributor

I has grown worse in v1.1.12 - we weren't really affected in v1.1.11 and previous versions.

@Santiagoebizmarts
Copy link
Contributor

Santiagoebizmarts commented Mar 12, 2018

@m-overlund I guess you mean 1.1.11 because there is no 1.1.12 yet.

Please try the fix below, according to @mzeis this should solve the problem.
Let me know if it helps.

Regards.

Santiagoebizmarts added a commit that referenced this issue Mar 12, 2018
@m-overlund
Copy link
Contributor

@Santiagoebizmarts , yeah, meant after upgrading from .10 to .11.
It does work as a quick fix and makes the issue less urgent - thanks.

But the underlying issue is still there, as @ikk0 pointed out, and will still collide with other modules and people who does not use AOE scheduler for cron.

@m-overlund
Copy link
Contributor

The commit isn't a solution to the problem.
I also think it's a bad workaround, as it isn't plug n play.
It doesn't change anything, as you manually have to add execution of the cron group, if you use aoe_scheduler at all, that is.

Please consider reopening

@MurKit
Copy link

MurKit commented May 3, 2018

@Santiagoebizmarts The commit does not work as a quick fix too.
After applying the changes, the error continues to appear.
Am I missing something?

Second thought:
can it be that error is because there is no model specified in the Scheduler?

screenshot at 2018-05-03 15-27-18

@ikk0
Copy link

ikk0 commented Aug 24, 2018

See here for a guide on how to move your Mailchimp crons into a separate cron group: https://support.xtento.com/wiki/AOE_Scheduler:_Invalid_model_/_method_definition#Possible_fix_when_using_Mailchimp_in_Magento_1

Make sure to use a recent version of the Mailchimp module to make sure it supports cron groups. (I am not sure if older versions specify the cron group in the section of config.xml, so better use the latest version)

This is not a fix of the problem in the Mailchimp module but rather just a solution to get your XTENTO crons and any other crons that use dynamic cron injection to run again. By separating the Mailchimp crons from all other crons, this will do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants