Class does not exist vendor/laravel/framework/src/Illuminate/Container/Container.php:790 - laravel

I'm having problems finding where this error is coming from.
Can anyone shed some light on this error?
I have cleared all cache files and checked the config files for errors.The file is physically there when I use the server's file explorer.
This error occurs on the staging server, running cpanel php7.1. Had no problems while using the local development server.
The stack trace:
[2019-07-06 06:44:49] online.ERROR: Class mollie does not exist {"userId":"70a84900-9fa7-11e9-a421-57dbf5e49d9b","exception":"[object] (ReflectionException(code: -1): Class mollie does not exist at /home/serv/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:790)
[stacktrace]
#0 /home/serv/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(790): ReflectionClass->__construct('mollie')
#1 /home/serv/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\\Container\\Container->build('mollie')
#2 /home/serv/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\\Container\\Container->resolve('mollie', Array)
#3 /home/serv/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\\Container\\Container->make('mollie', Array)
#4 /home/serv/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(1225): Illuminate\\Foundation\\Application->make('mollie')
#5 /home/serv/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(175): Illuminate\\Container\\Container->offsetGet('mollie')
#6 /home/serv/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(144): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance('mollie')
#7 /home/serv/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(231): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#8 /home/serv/app/app/Http/Controllers/PaymentController.php(62): Illuminate\\Support\\Facades\\Facade::__callStatic('api', Array)
#9 [internal function]: App\\Http\\Controllers\\PaymentController->preparePayment('starter')
the mollie class comes from the official Mollie payment package
https://github.com/mollie/laravel-mollie/blob/master/src/Facades/Mollie.php
I am using it the way the docs describe:
$payment = Mollie::api()->payments()->create([
'amount' => [
'currency' => 'EUR',
'value' => $totalAmount, // You must send the correct number of decimals, thus we enforce the use of strings
],
'description' => $totalCoins,
'webhookUrl' => route('order.hook'),
'redirectUrl' => route('order.success'),
]);
This is the first occurance for Mollie in that method

So in your PaymentController you are referencing a class called mollie which could not be found, physically it is there but you need to import it in your controller in order to be found.
So you might be missing some of this:
use App\mollie; // as an example of import / I don't know the namespace of the file
in your class mollie you forgot to add the namespace

Related

Fatal Error When Set CI_DEBUG to False On Production Mode Codeigniter 4

Why I get this error when set from Config/Boot/production.php CI_DEBUG to false in production mode ? this is the default setting from CI4.
defined('CI_DEBUG') || define('CI_DEBUG', false);
Fatal error: Declaration of CodeIgniter\Log\Logger::emergency($message, array $context = []): bool must be compatible with Psr\Log\LoggerInterface::emergency(Stringable|string $message, array $context = []): void in E:\testing\Source Code\testing_CI_v.4.2.6\system\Log\Logger.php on line 157
Fatal error: Uncaught Error: Class "CodeIgniter\Log\Logger" not found in E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php:391 Stack trace: #0 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(253): CodeIgniter\Config\Services::logger(false) #1 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #2 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php(388): CodeIgniter\Config\BaseService::getSharedInstance('logger') #3 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(253): CodeIgniter\Config\Services::logger(true) #4 E:\testing\Source Code\testing_CI_v.4.2.6\system\Common.php(799): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #5 E:\testing\Source Code\testing_CI_v.4.2.6\system\Debug\Exceptions.php(114): log_message('critical', '{message}\nin {e...', Array) #6 E:\testing\Source Code\testing_CI_v.4.2.6\system\Debug\Exceptions.php(180): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #7 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #8 {main} thrown in E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php on line 391
For Development And Testing Mode run without problem. This error just occur when using routes->resource (RESTFUL API).
It is not clear what error is this. I try to replace the system folder with new one. But the error still exists.
It is said "Uncaught Error: Class "CodeIgniter\Log\Logger" not found" I don't know what is the problem with this and why it is not found.
Now my app just run with set CI_DEBUG to true to prevent the error. But the default is set to false for production.
defined('CI_DEBUG') || define('CI_DEBUG', true);
What is missing in here ? It is so strange that setting the CI_ENVIRONMENT to development or testing worked without a problem. But for production not working. So I decide to turn on the error display in production mode and found the error above.
Seriously help need.
I found the problem in the restful api.
The problem is in the config/filter.php
$routes->resource('ApiManageTips', ['controller' =>'App\Controllers\ApiData\ApiManageTips']); // get, put, create, delete
public $filters = [
'basicauth' => ['before' =>
[
'ApiManageTips/*',
'ApiManageTips',
]
]
];
The Above example is working in the version 4.1.2 but is not working in version 4.2.6
Instead change to :
public $filters = [
'basicauth' => ['before' =>
[
'ApiManageTips/*',
]
];
I don't why it is not working in the CI Version 4.2.6.

Magento Error while trying to order / cancel an order that has more than one item

Hy
After the onepage checkout, in Magento, I received the following email error message
...
Payment transaction failed.
Reason
Mage registry key "_singleton/model/observer" already exists
Checkout Type
onepage
....
And on the admin page, when trying to delete this oreder, same error, again:
There has been an error processing your request
Mage registry key "_singleton/model/observer" already exists
Trace:
#0 /app/Mage.php(223): Mage::throwException('Mage registry k...')
#1 /app/Mage.php(478): Mage::register('_singleton/mode...', false)
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('model/observer')
#3 /app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('cataloginventor...', Array)
#4 /app/code/core/Mage/Core/Model/Abstract.php(466): Mage::dispatchEvent('cataloginventor...', Array)
#5 /app/code/core/Mage/CatalogInventory/Model/Stock/Item.php(787): Mage_Core_Model_Abstract->_afterSave()
#6 /app/code/core/Mage/Core/Model/Abstract.php(319): Mage_CatalogInventory_Model_Stock_Item->_afterSave()
#7 l/app/code/core/Mage/CatalogInventory/Model/Stock.php(210): Mage_Core_Model_Abstract->save()
#8 /app/code/core/Mage/CatalogInventory/Model/Observer.php(809): Mage_CatalogInventory_Model_Stock->backItemQty('542', 1)
#9 /app/code/core/Mage/Core/Model/App.php(1338): Mage_CatalogInventory_Model_Observer->cancelOrderItem(Object(Varien_Event_Observer))
#10 /app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_CatalogInventory_Model_Observer), 'cancelOrderItem', Object(Varien_Event_Observer))
#11 /app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('sales_order_ite...', Array)
..and so on
This only happends to orders that have more than one item.
Any help will be appreciated, especially because the website is in production now.
Many thanks
Let me add a bit of Magento 'anatomy' to Alan's answer:
From your error log:
#10 /app/code/core/Mage/Core/Model/App.php(1317): `Mage_Core_Model_App->_callObserverMethod(Object(Mage_CatalogInventory_Model_Observer), 'cancelOrderItem', Object(Varien_Event_Observer))
class: Mage_CatalogInventory_Model_Observer
model: cataloginventory/observer
method: cancelOrderItem
This mean what #2 should be:
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('cataloginventory/observer')
But you have:
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('model/observer')
Why it failed:
1) when Magento try to execute Mage::getSingleton('model/observer') it call getSingleton() function from Alan's answer.
2) registry don't have '_singleton/model/observer' so it try to register it:
self::register($registryKey, self::getModel($modelClass, $arguments));
3) it call self::getModel('model/observer', array())) for registration and this method fails because you don't have such model.
Again, you have 'model/observer' model in one of your xml configuration files, but Magento can't find physical file with this model.
What to do?
This is occurs on 'sales_order_item_cancel' event, so try to find this string in config.xml files in third-party extension folders.
If in one of config.xml you find something like:
...
<events>
...
<sales_order_item_cancel>
<observers>
<inventory>
<class>model/observer</class>
<method>cancelOrderItem</method>
</inventory>
</observers>
</sales_order_item_cancel>
...
</events>
...
Just comment <sales_order_item_cancel> section.
If you want to make it working, set correct value in <class>model/observer</class> section.
That's a curious error -- my guess is you're dealing with a "core-hack"/edut (perhaps unintentionally) of your app/Mage.php file.
If you look at your stack trace, Magento calls
Mage::getSingleton('model/observer')
This is Magento's ways of saying "Instantiate a model/observer object, and make it a singleton instance", If you're not familiar with them, singletons are a "global" object that can only be instantiated once. If you try to instantiate a singleton again you get the original instance.
If you look at the implementation of getSingleton
#File: app/Mage.php
public static function getSingleton($modelClass='', array $arguments=array())
{
$registryKey = '_singleton/'.$modelClass;
if (!self::registry($registryKey)) {
self::register($registryKey, self::getModel($modelClass, $arguments));
}
return self::registry($registryKey);
}
You can see the call to self::registry from your stack trace that causes the error. However, you can also see that Magento checks to make sure the registry key doesn't exist via the if (!self::registry($registryKey)) { conditional.
My guess is someone changed the definition of getSingleton, or registry or register in your app/Mage.php file. In a sock Magento system it should not be possible to receive the exact error you've posted here.

Magento page freeze/blank after account creation

RE: EE v1.10.1.1
Hello,
Recently I've discovered that registration process page freezes after a user submits the form to create an account. It dies on '/customer/account/createpost/'.
Seems to die on this line in the /app/code/core/Mage/Customer/controllers/AccountController.php around line #325 ($session->setCustomerAsLoggedIn($customer);).
It seems to choke on an invalid/empty session when going to set user as logged in. Only after refreshing the frozen page wlll it logs/displays an error. I haven't found any other errors/warnings/messages that are logged... in any of the logs (to include server logs):
a:5:{i:0;s:62:"Mage registry key "_singleton/customer/session" already exists";i:1;s:1247:"#0 /server_path/html/app/Mage.php(192): Mage::throwException('Mage registry k...')
#1 /server_path/html/app/Mage.php(446): Mage::register('_singleton/cust...', Object(Mage_Customer_Model_Session))
#2 /server_path/html/app/code/core/Mage/Customer/controllers/AccountController.php(50): Mage::getSingleton('customer/sessio...')
#3 /server_path/html/app/code/core/Mage/Customer/controllers/AccountController.php(75): Mage_Customer_AccountController->_getSession()
#4 /server_path/html/app/code/core/Mage/Core/Controller/Varien/Action.php(409): Mage_Customer_AccountController->preDispatch()
#5 /server_path/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('create')
#6 /server_path/html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 /server_path/html/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch()
#8 /server_path/html/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#9 /server_path/html/index.php(95): Mage::run('', 'store')
#10 {main}";s:3:"url";s:25:"/customer/account/create/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:2:"sg";}
The next line (#326) sends the welcome email. If line #325 is commented out then the email is still sent and, if this is done, the very first attempt to login to their account chokes on '/customer/account/loginPost/' on line #137:
$session->login($login['username'], $login['password']);
Refreshing the page one time displays the dashboard.
Either way the account appears to be created properly and account functionality is normal afterwards, no other login issues.
There have been a few recent changes, but none of them should have anything to do with the customer and/or customer/sessions... at least not that I'm aware of.
By chance does anyone have an idea on any common potential magento pitfalls in code... where I could have done something indirectly in another script/mod that would cause something like this?
I've been going over this way longer than I should and feel I've circled back to the starting point without any leads/success. I kinda feel like I'm missing/overlooking something obvious. Any input, thoughts, suggestions or ideas are appreciated.
Thanks.
Respectfully,
JamesD
[b]Note:[/b] The last time I personally checked this functionality was a month or two ago and it wasn't doing this. I have made/added a few custom mods since, but again they should not be 'directly' connected to customers and/or customer sessions.
Also, over a year ago we did add some additions to the 'customer_login' and 'customer_before_save' events, but there haven't been any issues with them in the past, so I wouldn't think either of these would be the cause.. The only other change would be a Magento upgrade from EE 1.9 to 1.10.
Empty session example....
Here's what the session looks like when the page chokes:
Mage_Customer_Model_Session Object
(
[_customer:protected] =>
[_isCustomerIdChecked:protected] =>
[_skipSessionIdFlag:protected] =>
[_data:protected] => Array
(
[_session_validator_data] => Array
(
[remote_addr] => 155.77.22.255
[http_via] =>
[http_x_forwarded_for] =>
[http_user_agent] => Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
)
[session_hosts] => Array
(
[www.slimgenics.com] => 1
)
[id] =>
[messages] => Mage_Core_Model_Message_Collection Object
(
[_messages:protected] => Array
(
)
[_lastAddedMessage:protected] => Mage_Core_Model_Message_Success Object
(
[_type:protected] => success
[_code:protected] => Thank you for registering.
[_class:protected] =>
[_method:protected] =>
[_identifier:protected] =>
[_isSticky:protected] =>
)
)
[before_auth_url] => https://www.domain.com/customer/account/index/
[no_referer] => 1
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
The error you describe should raise here (magento CE 1.7.0.2 for reference):
// app/Mage.php:472
$registryKey = '_singleton/'.$modelClass;
if (!self::registry($registryKey)) {
self::register($registryKey, self::getModel($modelClass, $arguments));
}
So it is checked immediatly before the registration wether this key exists. I don't think, the EE code does something else. So the question you have to answer is: Why is !self::registry($registryKey) false?
You have luck I dug deeper. I think the creation of the Session-Object fails and returns false. This means the check for the key is true, but the check in Mage::register() failse, because it checks with isset():
// app/Mage.php:216
public static function register($key, $value, $graceful = false)
{
if (isset(self::$_registry[$key])) {
if ($graceful) {
return;
}
self::throwException('Mage registry key "'.$key.'" already exists');
// [...]
The question is: why fails the creation of the session object.
The problem has been solved.
The problem stemmed from a change in a file that I was unaware of.
That change apparently caused a loop (where it was dying) throwing a 'Cannot redeclare' message. Caused from a 'require' statement in a file that was being called multiple times.
The only way I found this out was from a custom API. I used it to test the account creation functionality and fortunately the Soap handler was able to throw the error and log it within the Magento error.log (which it never did before). That 'redeclare' error message was in there and led me to the file that had been changed.
Thanks to all of you for your input.

error when using createEntityTables

I get this error when I include
$installer->createEntityTables( $this->getTable('red/red') );
I am using enterprise 1.11
I have also seen alternative to that is type every thing which is really time consuming. Could someone please tell me who to make this function work.
[previous:Exception:private] =>
[xdebug_message] => ( ! ) Mage_Eav_Exception: Can't create table: red_faqs_eavexample in C:\wamp\www\ubt.onlocal.com.au\app\Mage.php on line 549
Call Stack
#TimeMemoryFunctionLocation
10.0003690528{main}( )..\index.php:0
20.00271167384Mage::run( )..\index.php:81
30.01012776112Mage_Core_Model_App->run( )..\Mage.php:640
40.02304545784Mage_Core_Model_App->_initModules( )..\App.php:338
50.46364871080Mage_Core_Model_Resource_Setup::applyAllUpdates( )..\App.php:412
60.528411772936Mage_Core_Model_Resource_Setup->applyUpdates( )..\Setup.php:235
70.528611769664Mage_Core_Model_Resource_Setup->_installResourceDb( )..\Setup.php:327
80.528611769824Mage_Core_Model_Resource_Setup->_modifyResourceDb( )..\Setup.php:421
90.529511778144include( 'C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php' )..\Setup.php:624
100.529711778712Mage_Eav_Model_Entity_Setup->createEntityTables( )..\install-0.1.0.php:6
)
Error in file: "C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php" - Can't create table: red_faqs_eavexample
#0 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#2 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#3 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(412): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(338): Mage_Core_Model_App->_initModules()
#6 C:\wamp\www\ubt.onlocal.com.au\app\Mage.php(640): Mage_Core_Model_App->run(Array)
#7 C:\wamp\www\ubt.onlocal.com.au\index.php(81): Mage::run('', 'store')
#8 {main}
This is a problem with an error being triggered when it shouldn't be. Long story short, MySQL doesn't support DDL transactions, and in the course of the method DDL routines are being found in the SQL and an error is thrown.
The easy answer is to comment out this line:
lib/Varien/Db/Adapter/PDO/Mysql.php
protected function _checkDdlTransaction($sql)
{
if (is_string($sql) && $this->getTransactionLevel() > 0) {
$startSql = strtolower(substr(ltrim($sql), 0, 3));
if (in_array($startSql, $this->_ddlRoutines)) {
// comment this out: trigger_error(Varien_Db_Adapter_Interface::ERROR_DDL_MESSAGE, E_USER_ERROR);
}
}
}
Doing so allows your module to install. Obviously hacking a core file is a terrible idea. You should extend the method or allow the SQL to run, and then translate the generated SQL into the Magento MySQL API, as seen in core sql setup scripts. The latter is a major pain.. the better idea would be to extend the method.
More here on background information and troubleshooting.

Magento model collections - save data

So I'm loading a collection of products using this code:
$magento_time= 'some time string';
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addFieldToFilter(array(
array('attribute'=> 'updated_at', 'gt'=> date('Y-m-d H:i:s', strtotime($magento_time))),
));
$collection->save();
And getting this error in return on save:
Warning: Invalid argument supplied for foreach() in /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 970
#0 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(970): mageCoreErrorHandler(2, 'Invalid argumen...', '/var/www/magent...', 970, Array)
#1 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(925): Mage_Eav_Model_Entity_Abstract->_collectSaveData(Object(Mage_Catalog_Model_Product))
#2 /var/www/magento/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Product))
#3 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(845): Mage_Core_Model_Abstract->save()
#4 /var/www/magento/app/code/local/MyModule/controllers/IndexController.php(16): Mage_Eav_Model_Entity_Collection_Abstract->save()
#5 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(376): MyModule_IndexController->sayHelloAction()
#6 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch('sayHello')
#7 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /var/www/magento/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#9 /var/www/magento/index.php(68): Mage::run()
#10 {main}
How do I save products back to the database after they've been loaded into a collection?
Changing the following worked for me:
Manually set the current store:
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
Save each collection independently.
foreach ($collection as $entry) {
$entry->save();
}
EDIT:
Note the Magento API has changed significantly since I first asked this question ~2.5 years ago - this answer may no longer apply.
You do a foreach and save elements one by one.

Resources