Magento Admin > System > Configuration > Advanced > System - Fatal Error - magento

I get this error when I try to access System > Configuration > Advanced > System
Fatal error: Call to a member function toOptionArray() on a non-object in /home/server/public_html/store/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 421
I found this answer: Fatal error: Call to a member function toOptionArray()
However, the code that needs to be replaced according to that answer is different from the code in that file (Form.php):
if ($method) {
if ($fieldType == 'multiselect') {
$optionArray = $sourceModel->$method();
} else {
$optionArray = array();
foreach ($sourceModel->$method() as $value => $label) {
$optionArray[] = array('label' => $label, 'value' => $value);
}
}
} else {
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
}
$field->setValues($optionArray);
}
}
}
return $this;
Any ideas? Thanks!

If you look in Form.php from line 398 to 425 you have almost the same code. The code from your answer isn't a fix, is just a way to help you determine your real problem, so you can use that code:
if(is_object($sourceModel)){
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
Mage::log($e->source_model);
}
And then you would have to look into the Magento log file to see what happened.
Also you can try to log debug_print_backtrace();
Probably your problem comes from a badly written extension.

The following steps should solve the error:-
Disable Compilation (System -> Tools -> Compilation)
Refresh Cache (System -> Cache Management)

Related

Redirect with ci flash message Connot modify header information error occue

I'm trying to redirect after executing some code with flash message then apache hang and sent error
Connot modify header information - headers already sent
public function convert_to_invoice($id)
{
if (!has_permission('invoices', '', 'create')) {
access_denied('invoices');
}
if (!$id) {
die('No estimate found');
}
$draft_invoice = false;
if ($this->input->get('save_as_draft')) {
$draft_invoice = true;
}
$invoiceid = $this->estimates_model->convert_to_invoice($id, false, $draft_invoice);
if ($invoiceid) {
$this->session->set_flashdata('message-success','estimate_convert_to_invoice_successfully');
redirect('invoices/list_invoices/' . $invoiceid);
} else {
if ($this->session->has_userdata('estimate_pipeline') && $this->session->userdata('estimate_pipeline') == 'true') {
$this->session->set_flashdata('estimateid', $id);
}
if ($this->set_estimate_pipeline_autoload($id)) {
redirect($_SERVER['HTTP_REFERER']);
} else {
redirect(admin_url('estimates/list_estimates/' . $id));
}
}
}
As redirect uses headers to perform its task nothing can be outputted before it is called. I don't see anything that would cause output except:
if (!has_permission('invoices', '', 'create')) {
access_denied('invoices'); // exits?
}
if (!$id) {
die('No estimate found');
}
However both seem to exit so the redirect stage shouldn't be reached.
I would suggest removing the redirects temporarily, running the script, and seeing what is outputting. You can then remove/silence those offending pieces of code and re-institute the redirects. It might be as simple as an error outputting.

How to fix laravel migrate receiving "Curl error (code 3): <url> malformed"?

I just pulled some updates in a repository. Then when I use the command "php artisan migrate" it gives me an error. See the screenshot below.
How can I fix this?
Or what seems to be causing this?
Thank you!
Edit
Heres the code for Util.php. But I don't think I should be messing with it since it came from vendors directory.
<?php
namespace Monolog\Handler\Curl;
class Util
{
private static $retriableErrorCodes = array(
CURLE_COULDNT_RESOLVE_HOST,
CURLE_COULDNT_CONNECT,
CURLE_HTTP_NOT_FOUND,
CURLE_READ_ERROR,
CURLE_OPERATION_TIMEOUTED,
CURLE_HTTP_POST_ERROR,
CURLE_SSL_CONNECT_ERROR,
);
public static function execute($ch, $retries = 5, $closeAfterDone = true)
{
while ($retries--) {
if (curl_exec($ch) === false) {
$curlErrno = curl_errno($ch);
if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) {
$curlError = curl_error($ch);
if ($closeAfterDone) {
curl_close($ch);
}
throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrno, $curlError));
}
continue;
}
if ($closeAfterDone) {
curl_close($ch);
}
break;
}
}
}
Not a permanent fix, but rather than have this you can commented it out throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError)); and the I had return true;

$cofig [modules_locations] not loading datatable

I am using HMVC codeigniter 3. I have a folder called admin under and in that folder I have a subfolder called client. In my config file, i have set up the module path like this;
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
APPPATH.'modules/admin/' => '../modules/admin/',
);
Now, the problem is, its loadig my client controller but its not loading my entites. it is showing me the following error;
> An uncaught Exception was encountered
>
> Type: Doctrine\ORM\Query\QueryException
>
> Message: [Semantical Error] line 0, col 109 near 'entities\AppClient':
> Error: Class 'entities\AppClient' is not defined.
Please help me to solve this issue..This client module works fine, if i moved it from sub module to only modules folder
solved it...Add the following function in doctorine.php
private function _recursiveDir(&$array, $directory)
{
$scanned_dir = array_diff(scandir($directory), array('..', '.'));
sort($scanned_dir);
$subModules = array(
"admin"
);
foreach ($scanned_dir as $module) {
if (is_dir($directory.$module."/models")) {
$array[] = $directory.$module."/models/doctrine/entities";
} else if (in_array($module, $subModules)) {
$this->_recursiveDir($array, $directory.$module."/");
}
}
}

New Caller Insert to Database with Codeigniter using the Twilio API

Below is the function to receive all incoming calls in my Controller
public function call_incoming()
{
$blocklist = $this->call_log_model->get_blocklist($_REQUEST['From']);
$tenantNum = $this->call_log_model->get_called_tenant($_REQUEST['From']);
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_tenant);
$officeStatus = $this->check_office_hours($tenantInfoByNumber->start_office_hours, $tenantInfoByNumber->end_office_hours);
$calldisposition = $this->calldisp_model->get_call_disposition($tenantInfoByNumber->user_id);
$response = new Services_Twilio_Twiml;
if($blocklist == 0)
{
if($officeStatus == "open")
{
if($_POST['Called'] != AGENTPOOL_NUM)
{
$data = array(
'caller'=>$_REQUEST['From'],
'to_tenant'=>$_POST['Called'],
'date_created'=>date('Y-m-d H:i:s')
);
$this->call_log_model->insert_caller_to_tenant($data);
$dial = $response->dial(NULL, array('callerId' => $_REQUEST['From']));
$dial->number(AGENTPOOL_NUM);
print $response;
}
else
{
$gather = $response->gather(array('numDigits' => 1, 'action'=>HTTP_BASE_URL.'agent/call_controls/call_incoming_pressed', 'timeout'=>'5' , 'method'=>'POST'));
$ctr = 1;
foreach($calldisposition as $val )
{
$gather->say('To go to '.$val->disposition_name.', press '.$ctr, array('voice' => 'alice'));
$gather->pause("");
$ctr++;
}
print $response;
}
}
else
{
$response->say('Thank you for calling. Please be advise that our office hours is from '.$tenantInfoByNumber->start_office_hours.' to '.$tenantInfoByNumber->end_office_hours);
$response->hangup();
print $response;
}
}
else
{
$response->say('This number is blocked. Goodbye!');
$response->hangup();
print $response;
}
}
Please advise if I need to post the model...
Here is whats happening everytime an unknown number calls in, the caller will hear an application error has occurred error message and when checking the Twilio console the error it is giving me is
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: agent/Call_controls.php
Line Number: 357
Please be advised that this error only occurs when the caller is a number not in our database yet. When the call comes from a number already saved in our databse, this codes works...
Thank you for the help...
if($tenantNum) {
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_t‌​enant);
} else {
$tenantInfoByNumber = ""; // fill this in with relevant fill data
}
This should fix your issue, as there is no TenantNum returned, there is no data, so make it yourself for unknown numbers.

Laravel 4 using nikic phpparser : Going out of memory when sending email

Just learned that Laravel using nikic phpparser internally.
I modified my code to sending emails on one of the conditions & it started dying.
The PHP logs showed this :
[Sat Oct 03 21:18:23 2015] [error] [client xx.xx.xx.xx] PHP Fatal
error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 1048576 bytes) in
/home/yyyy/public_html/vendor/nikic/php-parser/lib/PHPParser/NodeTraverser.php
on line 66, referer: http://yyyy.com/home
Temporarily I've increased the memory to resolve the issue.
But, I want to move away from the band-aid.
I see that the NodeTraverser function is doing a clone, would that cause the problem :
protected function traverseNode(PHPParser_Node $node)
{
ini_set('memory_limit', '64M'); // temporary fix
$node = clone $node;
foreach ($node->getSubNodeNames() as $name) {
$subNode =& $node->$name;
if (is_array($subNode)) {
$subNode = $this->traverseArray($subNode);
} elseif ($subNode instanceof PHPParser_Node) {
foreach ($this->visitors as $visitor) {
if (null !== $return = $visitor->enterNode($subNode)) {
$subNode = $return;
}
}
$subNode = $this->traverseNode($subNode);
foreach ($this->visitors as $visitor) {
if (null !== $return = $visitor->leaveNode($subNode)) {
$subNode = $return;
}
}
}
}
return $node;
}
This is how I'm sending the email. This is no different than anywhere else, hence I doubt this would cause an issue :
$this->mailer->queue('emails.forreg',
[
'toName' => $toEmailName,
'fromName' => $user->username,
'site_name' => \Config::get('site_title')
],
function($mail) use($toEmailAddress, $user, $subject_to_send, $toEmailName)
{
$mail->to($toEmailAddress, $toEmailName)
->subject($subject_to_send)
->from('xxx#yyy.com', $user->username);
}
);
Any ideas on how to resolve this ?
You simply have an extreme low memory limit. IIRC PHP limit starts at 128M for a default. When the parser goes through it's building up a node for every single part of the code. Nothing is excluded and there's no easy hot fix.
Memory is cheaper than ever today and this problem is unlikely to be fixed because of the upcoming PHP7. Perhaps give that a try as it's likely to have a smaller memory footprint anyways.

Resources