Magento page freeze/blank after account creation - magento

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.

Related

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

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

cakePHP 3.0.7 - Unable to call method "" in "default" provider for field "member_selected"

In MembersTable.php I have:
$validator
->notEmpty('member_selected')
->add('member_selected', ['rule' => ['inList', [0,1], false]]);
return $validator;
I am receiving the following very cryptic message from cakePHP 3.0.7
Unable to call method "" in "default" provider for field member_selected" InvalidArgumentException
⟩ Cake\Validation\ValidationRule->process CORE\src\Validation\Validator.php, line 656
⟩ Cake\Validation\Validator->_processRules CORE\src\Validation\Validator.php, line 136
⟩ Cake\Validation\Validator->errors CORE\src\ORM\Marshaller.php, line 181
⟩ Cake\ORM\Marshaller->_validate CORE\src\ORM\Marshaller.php, line 428
⟩ Cake\ORM\Marshaller->merge CORE\src\ORM\Table.php, line 2034
⟩ Cake\ORM\Table->patchEntity APP/Controller\MembersController.php, line 104
⟩ App\Controller\MembersController->edit [internal function]
⟩ call_user_func_array CORE\src\Controller\Controller.php, line 411
⟩ Cake\Controller\Controller->invokeAction CORE\src\Routing\Dispatcher.php, line 114
⟩ Cake\Routing\Dispatcher->_invoke CORE\src\Routing\Dispatcher.php, line 87
⟩ Cake\Routing\Dispatcher->dispatch ROOT\webroot\index.php, line 37
If I remove the ->add('member_selected', ['rule' => ['inList' ...
every thing works ok, but of course the validation is not being done correctly. I do not have an example of the use if 'inList' but I think I've got it setup correctly. I have several other fields of this table that I've had to remove other validator rules from to get past this error message (e.g. naturalNumber).
I also will reference another stackoverflow question titled "cakePHP 3.0.7 - Baked edit function fails to perform save in patchEntity with Marshaller::merge() error."
The problems can be "resolved" by altering the $validator setting for one of the fields... One of ways to create these errors is to change field name or type, and forget to change it in Entity $_accessible, and Table $validator inside function validationDefault(). Also don't forget $rules->adds in Table::buildRules()
Of course... why would anyone want to change a field name or type? Oh well, it would be nice if cakePHP would give some information as to the actual problem (expected field does not exist, or field specified should not exist).
Anyway, now that I've blown off a little steam, the validator is not reporting anything useful when it blows up. I hope someone is watching stackoverflow so it can be resolved.
Having said all this, I'm still wondering why the 'inList' rule does NOT work?
Answer to why inList, and naturalNumber did not work for me!
add public
add( string $field , array|string $name , array|Cake\Validation\ValidationRule $rule [] )
Adds a new rule to a field's rule set. If second argument is an array then rules list for the field will be replaced with second argument and third argument will be ignored.
Example:
$validator
->add('title', 'required', ['rule' => 'notBlank'])
->add('user_id', 'valid', ['rule' => 'numeric', 'message' => 'Invalid User'])
$validator->add('password', [
'size' => ['rule' => ['lengthBetween', 8, 20]],
'hasSpecialCharacter' => ['rule' => 'validateSpecialchar', 'message' => 'not valid']
]);
Well, it's not true! You cannot leave out the second argument! All errors during validation (which are incorrectly reported as far as I'm concerned) go away if I always specify the second arg and then the 3rd arg specifies the rules!
Thanks to everyone who may read and offer assistance,
You forgot to give your rule a 'name' of your own liking
->add('member_selected', 'rule_name', ['rule' => ['inList', [0,1], false]]);

InstantCommons not working in MediaWiki 1.19 and SELinux

I am setting my own MediaWiki website locally, and am not able to get the InstantCommons feature to work (used to directly embed files from commons.wikimedia.org).
I get no error message, the files I try to load from Commons using the following syntax:
[[File:Cervus elaphus Luc Viatour 1.jpg|Cervus elaphus Luc Viatour 1]]
are just not loaded, and I end up with a red link on my page, referring to a non-existing file. It has been 2 days now that I am looking for a solution, but so far without any success.
I am running:
MediaWiki v.1.19.1
Fedora 16 (with SElinux)
PHP 5.3.15
MySQL Ver 14.14 Distrib 5.5.25a, for Linux (x86_64)
I have tried the following two configurations in my LocalSettings.php, without success:
$wgUseInstantCommons = true;
AND
$wgForeignFileRepos[] = array(
'class' => 'ForeignAPIRepo',
'name' => 'shared',
'apibase' => 'http://commons.wikimedia.org/w/api.php',
'fetchDescription' => true, // Optional
'descriptionCacheExpiry' => 43200, // 12 hours, optional (values are seconds)
'apiThumbCacheExpiry' => 43200, // 12 hours, optional, but required for local thumb caching
);
Any suggestion is most welcome.
OK, this is not (yet) an answer, but a debugging suggestion. It looks to me like the HTTP request from your server to Commons is failing for some reason, but unfortunately ForeignAPIRepo doesn't indicate the cause of the error in any way.
This is really a bug in MediaWiki, and should be fixed, but in the mean time, could you please try applying the following diff (or just manually adding the line marked with the + sign) to your includes/filerepo/ForeignAPIRepo.php file:
Index: includes/filerepo/ForeignAPIRepo.php
===================================================================
--- includes/filerepo/ForeignAPIRepo.php (revision 97048)
+++ includes/filerepo/ForeignAPIRepo.php (working copy)
## -385,6 +385,7 ##
if ( $status->isOK() ) {
return $req->getContent();
} else {
+ wfDebug( "ForeignAPIRepo: HTTP GET failed: " . $status->getXML() );
return false;
}
}
After applying it, try loading the file description page for a Commons image and look at the MediaWiki debug log. There should now be a line starting with ForeignAPIRepo: HTTP GET failed: followed by a few lines of XML error dump. That error data should hopefully indicate what's going wrong; please copy and paste it here.
Mine is not a definitive answer either. Referring to Ilmari Karonen's post, I was unable to find or get the getXML() method to execute for my version of Mediawiki v1.23.0. I was looking at the reference documentation found here to try and find any other method calls on the Status class that would give me good troubleshooting info. I ended up finding the following and editing the same file as mentioned in Ilmari Karonen's post includes/filerepo/ForeignAPIRepo.php beginning at line #521:
if ( $status->isOK() ) {
return $req->getContent();
} else {
$error = $status->getErrorsArray();
$dump = print_r($error, true);
wfDebug("ForeignAPIRepo: HTTP GET failed: $dump\n");
return false;
}
The default InstantCommons configuration of older MediaWikis is a bit silly. Due to T114098 I recommend one of the following, which will hopefully fix your problems:
upgrade to MediaWiki 1.27 (when it's released), or
set your LocalSettings.php to hotlink images to save on server-side requests and processing.
$wgUseInstantCommons = false;
$wgForeignFileRepos[] = array(
'class' => 'ForeignAPIRepo',
'name' => 'commonshotlink',
'apibase' => 'https://commons.wikimedia.org/w/api.php',
'hashLevels' => 2,
'url' => 'https://upload.wikimedia.org/wikipedia/commons',
'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
'transformVia404' => true,
'fetchDescription' => true,
'descriptionCacheExpiry' => 43200,
'apiThumbCacheExpiry' => 24 * 3600,
);

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.

StructureMap Class Chaining - Stack Overflow or other errors

This has completely baffled me on a number of configurations. I keep reading the documentation, and I just don't get it. Here is my registration code:
ForRequestedType<SimpleWorkItemProcessor>().TheDefault.Is.OfConcreteType<SimpleWorkItemProcessor>();
ForRequestedType<WorkItemRetryProcessor>().TheDefault.Is.OfConcreteType<WorkItemRetryProcessor>()
.CtorDependency<IWorkItemProcessor>().Is(x => x.OfConcreteType<SimpleWorkItemProcessor>())
.WithCtorArg("busyDelay").EqualTo(TimeSpan.FromMilliseconds(20))
.WithCtorArg("overallTimeout").EqualTo(TimeSpan.FromSeconds(60));
ForRequestedType<WorkItemQueue>().TheDefault.Is.OfConcreteType<WorkItemQueue>()
.CtorDependency<IWorkItemProcessor>().Is(x => x.OfConcreteType<WorkItemRetryProcessor>());
As it is, it says there's no default instance for IWorkItemProcessor (which is correct). Switching the last line to this:
ForRequestedType<IWorkItemProcessor>().TheDefault.Is.OfConcreteType<WorkItemQueue>()
.CtorDependency<IWorkItemProcessor>().Is(x => x.OfConcreteType<WorkItemRetryProcessor>());
...Makes a stack overflow exception.
How do you chain classes together that both implement an interface, and take in that same interface in their constructor?
This works, but I can't explain why. From what I know, the first version should work just as well.
ForRequestedType<SimpleWorkItemProcessor>().TheDefault.Is.OfConcreteType<SimpleWorkItemProcessor>();
var retryProcessor = ForRequestedType<WorkItemRetryProcessor>().TheDefault.Is.OfConcreteType<WorkItemRetryProcessor>()
.CtorDependency<IWorkItemProcessor>().Is(x => x.OfConcreteType<SimpleWorkItemProcessor>())
.CtorDependency<TimeSpan>("busyDelay").Is(x => x.Object(TimeSpan.FromMilliseconds(20)))
.CtorDependency<TimeSpan>("overallTimeout").Is(x => x.Object(TimeSpan.FromSeconds(60)));
ForRequestedType<IWorkItemProcessor>().TheDefault.Is.OfConcreteType<WorkItemQueue>()
.CtorDependency<IWorkItemProcessor>("workItemProcessor").Is(x => x.Instance(retryProcessor));

Resources