Magento: what did I break? "Fatal error: Call to a member function insert()" (version 1.4.1.1) - php

I was trying to implement some new functionality, decided not to, tried to roll back, and now am stuck with this error:
Fatal error: Call to a member function insert() on a non-object in /app/code/core/Mage/Core/Model/Mysql4/Resource.php on line 96
The functionality I mentioned seems simple enough (remove a couple links from the customer account sidebar), and I believe I've removed the 3 files and the edit to local.xml, but just for full view on things, here's exactly what i did.
Add'l info: I've got one custom module in place that I built for this site, and it was working prior to this glitch, but I'm wondering if something got screwed up in there maybe? (And I'm also thinking I might not have committed my last/working change, and now I'm in "doubt" territory about whether I screwed that up. It's a simple one though: 1 controller, 1 route.)
I've got no access to PHP error logs or the shell (exec() works great though), and the /var/system.log isn't adding anything more on my subsequent page-refreshes. And so this is where I'm stuck - Got any ideas on how to track this down? Thanks in advance!
Edit / here's the function that's throwing the error:
function setDbVersion($resName, $version)
{
$dbModuleInfo = array(
'code' => $resName,
'version' => $version,
);
if ($this->getDbVersion($resName)) {
self::$_versions[$resName] = $version;
$condition = $this->_write->quoteInto('code=?', $resName);
return $this->_write->update($this->_resTable, $dbModuleInfo, $condition);
}
else {
self::$_versions[$resName] = $version;
// this is line 96:
return $this->_write->insert($this->_resTable, $dbModuleInfo);
}
}

Related

PHP Cannot redeclare function/Call to undefined function

I am using WooCommerce on Wordpress 4.7.1. Previously, I was running 4.7.0. When Wordpress automatically upgraded to 4.7.1, I suddenly began seeing checkouts fail to redirect to the "Thank you" page, and the UI showed that a fatal error had occurred.
Turning on debugging revealed the following error:
PHP Fatal error: Cannot redeclare get_cc() (previously declared in .../templates/emails/email-addresses.php:36) in .../templates/emails/email-addresses.php on line 36
I also confirmed that this file is never directly called with require, require_once, include, or include_once. It is, however, called with wc_get_template().
A quick search brought me to this similar question. So I added the following to email-addresses.php:
if (!function_exists('get_cc')) {
function get_cc( $code ) {
... function body
}
}
After making this change, I now receive the following error in the debug log:
PHP Fatal error: Call to undefined function get_cc() in .../templates/emails/email-addresses.php on line 32
This means that, for whatever reason, PHP believes that the function get_cc already exists, but at the same time it is undefined.
I was not the original developer. I took over the project from a contractor who is not available. It does seem clear that this file is heavily modified from the original. I am certain that the value returned by the function must be kept, so I cannot just comment out the call.
Given the information above, what options do I have to either workaround or fix this issue?
It turns out that, unlike a standard function definition in PHP, function definitions wrapped in if (!function_exists('function_name')) { ... } block must precede any call to that function.
In this case, the function definition (line 36) followed the call (line 32). This caused the function to appear to PHP as undefined:
// Not working!
$value = get_cc($code);
if (!function_exists('get_cc')) {
function get_cc( $code ) {
...
}
}
Switching the order so that the function definition came first fixed the issue:
// Working!
if (!function_exists('get_cc')) {
function get_cc( $code ) {
...
}
}
$value = get_cc($code);
As of right now, PHP's documentation does not mention this issue.

I am getting: "Non-static method Inflector::singularize() should not be called statically" when running MySQLConnector.php

I am trying to setup OData connection to MySQL database .. when I run the MySQLConnector.php , I am getting the above error.. can someone please direct me towards a solution.
The statement that gives the error is:
public function getEntityTypeName($entity)
{
return \Inflector::singularize($entity);
}
Following is the code in Inflector.php:
function singularize($word) {
$_this =& Inflector::getInstance();
if (isset($_this->_singularized[$word])) {
return $_this->_singularized[$word];
}
Please let me know if you would need any further information. Thanks in advance.
The short answer is: you need to update both of them. It looks like you have an older Inflector which is relying on deprecated PHP behaviour, and it's likely that your MySQLConnector.php is also old. If you don't update, you'll likely hit further problems.
In this case, PHP is complaining that you're using a static call to a method which is missing the "static" keyword. It's very likely that this message is a warning not an error, so it probably isn't causing whatever end problem you're experiencing. If you really want to address this message, you can just write static public function singularize($word) { instead, but like I said you will have more problems.

Issue upgrading Joomla 1.5 to Joomla 2.5

I'm having many issues upgrading a custom Joomla site from Joomla 1.5 to 2.5. I have the template installed on the back end, but the front end keeps displaying error messages. I don't really know too much PHP, so I'm having a hard time trying to figure out what is all going on.
First, I use jupgrade to upgrade the core of the site.
Then I followed this video to make the custom site template ready for Joomla 2.5:
http://www.youtube.com/watch?v=xqnm1DJn3jE
In my "/jupgrade/templates/my-template/menus/ folder there is a file called Base.class.php.
When I try to go the new home page of my site, in the /jupgrade/ folder, I get the following error:
Fatal error: Class 'JParameter' not found in ../public_html/jupgrade/templates/my-template/menus/Base.class.php on line 46
Line 46 reads:
function createParameterObject($param, $path='', $type='menu') {
return new JParameter($param, $path); }
According to this website (http://docs.joomla.org/Upgrading_a_Joomla_1.5_extension_to_Joomla_1.6#Converting_Your_JParameters_to_JForms) I need to change "JParameters" to "JForm".
When I change it, I now am getting the following error when going to the home page:
Catchable fatal error: Argument 2 passed to JForm::__construct() must be an array, string given, called in ../public_html/jupgrade/templates/my-template/menus/Base.class.php on line 46 and defined in ../public_html/jupgrade/libraries/joomla/form/form.php on line 80
Line 80 of the form.php file is:
public function __construct($name, array $options = array())
{
// Set the name for the form.
$this->name = $name;
// Initialise the JRegistry data.
$this->data = new JRegistry;
// Set the options if specified.
$this->options['control'] = isset($options['control']) ? $options['control'] : false;
}
Does anyone have any advice on how to solve this issue?
Actually you don't need to change JParameter to JForm. We had the exact issues before and we have explained them here.
JParameter is no longer included by default in Joomla 2.5. In short, you will need to include using the jinclude directive. That's actually the fastest way to solve your problem.
Revert back your changes and just include the JParameter class.

Fatal error: Call to a member function getPk() on a non-object (P4A, MySQL)

I'm Not too sure on what this error is, from looking around, it must be something to do with the database declarations. I'm trying to make a drop down box on my Widget, by selecting different fields of the database, different masks will be selected and will allow for different widgets to be made on later pages.
The part of my code where i think the error is, is:
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
I know its a similar question to my previous one, but its a different code entirely, but this one should be much easier to fix.
Thanks for the help.
The Stacktrace (Fatal error: Call to a member function getPk() on a non-object in C:\xampp\htdocs\p4a\p4a\objects\widgets\field.php on line 468) isn't indicating the line at which the error is occurring so i'm unsure where exactly the problem is originating from,
The rest of the code (including previous) is:
class main_dashboard_mask extends P4A_Base_Mask
{
public function __construct()
{
parent::__construct();
$this->setTitle("Dashboard");
$this->build('p4a_field','MeetingRooms');
$this->MeetingRooms->setLabel("This is the meeting room label");
$this->build('p4a_button', 'continue')
->setLabel('Continue?')
->implement("onclick", $this, "change");
$this->build('p4a_field','booking')
->setlabel('Viewing?')
->setType('checkbox')
->setValue(true);
$this->booking->label->setTooltip('If you are booking a meeting room, check this box');
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();
}
private function Meetingrooms()
{
$this->build('P4A_fieldset', 'widgetframe')
->anchor($this->location)
->anchorLeft($this->booking)
->anchorLeft($this->continue)
->setLabel('Meeting Room Bookings');
}
}
I think you are not getting the object. That is why it's giving error of non-object.
Just print the object on which you are calling the method getPk(). If it is valid object then
only call that method.
i got it, sorry i was looking in the right place but didn't see where i was wrong...
where before the code was ->
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login') // <- this is the error(the Pk variable hasn't been set here)
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();
the fix is ->
->setSource($this->login)
Thanks for the assistance =]
Do you have a full stacktrace ? What line of code exactly generates this error ?
Anyway, you have to locate the code where $object->getPk() is called. The error means that you're trying to use a function ->getPk() on an $object that is null ..

SOAP Error when trying to use the Cybersource module within Magento

I have tried to find a more specific answer and could not find anything helpful in regards to this error. It may simply be that I am unfamiliar with Magento or the cybersource module or both but either way, I just cannot understand what this message is trying to tell me.
This is an exception that not only shows up while debugging but also if I capture all SMTP traffic going out on my dev machine, it shows up in the email that you would get upon failure.
Exception: Strict Notice: Declaration of Mage_Cybersource_Model_Api_ExtendedSoapClient::__doRequest()
should be compatible with that of SoapClient::__doRequest() in
C:\code\app\code\local\Mage\Cybersource\Model\Api\ExtendedSoapClient.php on line 75
in C:\code\app\code\core\Mage\Core\functions.php on line 245
what I am doing when this occurs is trying to submit an order. I have added items to the shopping cart, logged in, put in shipping data and reviewed the order and when I hit Submit Order, it chunks for a while and gives me this message. When I debug through the code (which takes FOREVER) I finally get to the point where the cybersource module is trying to authorize through the SOAP system and then it throws this error.
the exact placement it errors is around this method
protected function getSoapApi($options = array())
{
$wsdl = $this->getConfigData('test') ? self::WSDL_URL_TEST : self::WSDL_URL_LIVE;
return new Mage_Cybersource_Model_Api_ExtendedSoapClient($wsdl, $options);
}
any ideas would be very helpful on what to look for or even what this message means. Also, I have SOAP installed and enabled in PHP 5.3.6 running in a windows environment with apache 2.2.
Thanks to Joe, I did some digging and found that Cybersource wrote its module to work with PHP5.2.1 and in that version the SOAP client was different than on PHP 5.3. the __doRequest method had an item added to it that was causing the inconsistency. so I changed the code in the ExtendedSoapClient.php file from
From
public function __doRequest($request, $location, $action, $version)
to
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
and that seemed to fix this error. Thanks Joe for your help into this error.
This is actually a PHP error about subclassing SoapClient. Basically, it happens when you have something like this:
class Foo {
public function doSomething() {
// ...
}
}
class Bar extends Foo {
public function doSomething($totallyUnreasonableParameter) {
// ...
}
}
Your issue is almost certainly an issue with the version of SOAP installed on your server. I haven't seen this in particular, but it could have to do with the PHP version (5.3.6) which I am not aware of as a supported version.
Hope that helps!
Thanks,
Joe

Categories