4

Good Morning! Getting an error all over the place after installing a module. I can't find much on Google about this kind of error. The module seems to work fine but I get this error:

2016-05-23T13:31:54+00:00 ERR (3): Warning: Declaration of EbayEnterprise_MultipleCoupons_Model_Validator::_canProcessRule(Mage_SalesRule_Model_Rule $rule, Mage_Sales_Model_Quote_Address $address) should be compatible with Mage_SalesRule_Model_Validator::_canProcessRule($rule, $address)  in /home/public_html/app/code/community/EbayEnterprise/MultipleCoupons/Model/Validator.php on line 15

Here is app/code/community/EbayEnterprise/MultipleCoupons/Model/Validator.php with the function _canProcessRule:

protected function _canProcessRule(Mage_SalesRule_Model_Rule $rule, Mage_Sales_Model_Quote_Address $address)
{
    /**
     * check if validation already occurred
     */
    if ($rule->hasIsValidForAddress($address) && $address->isObjectNew() === false) {
        return $rule->getIsValidForAddress($address);
    }

    /**
     * check per rule usage limit
     */
    if ($rule->getId() && $rule->getUsesPerCustomer() &&
        $this->isValidRuleUsageForAddress($rule, $address) === false
    ) {
        $rule->setIsValidForAddress($address, false);
        return false;
    }

    $rule->afterLoad();

Here is the place I believe the error is referring to app/code/core/Mage/SalesRule/Model/Rule.php:

public function getCouponTypes()
{
    if ($this->_couponTypes === null) {
        $this->_couponTypes = array(
            Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON => Mage::helper('salesrule')->__('No Coupon'),
            Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC  => Mage::helper('salesrule')->__('Specific Coupon'),
        );
        $transport = new Varien_Object(array(
            'coupon_types'                => $this->_couponTypes,
            'is_coupon_type_auto_visible' => false
        ));
        Mage::dispatchEvent('salesrule_rule_get_coupon_types', array('transport' => $transport));
        $this->_couponTypes = $transport->getCouponTypes();
        if ($transport->getIsCouponTypeAutoVisible()) {
            $this->_couponTypes[Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO] = Mage::helper('salesrule')->__('Auto');
        }
    }
    return $this->_couponTypes;
}

And here also app/code/core/Mage/Sales/Model/Quote/Address.php I find a couple places:

protected function _isSameAsBilling()
{
    return ($this->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
        && ($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()));
}

and here:

public function addShippingRate(Mage_Sales_Model_Quote_Address_Rate $rate)
{
    $rate->setAddress($this);
    $this->getShippingRatesCollection()->addItem($rate);
    return $this;
}

Anyone familiar with these kinds errors can help me?

  • 1
    I suggest you contact the module author. Your question will most likely be closed as questions about 3rd party modules are off topic. – Raphael at Digital Pianism May 23 '16 at 14:07
  • 2
    Is this really off topic if the module was created by Ebay when Magento was owned by Ebay? Let's leave it open for a while. – philwinkle May 23 '16 at 17:27
  • 1
    This is PHP error and, while the vendor should solve it, is something that can be solved by a programmer. Vote to keep open – Alan Storm May 23 '16 at 18:02
  • php warnings can safely be ignored, but just for you kind folks github.com/eBayEnterprise/magento-multi-coupons/pull/3 we'll see if they accept – ryaan_anthony May 23 '16 at 18:18
  • 1
    Ugh ugh ugh ugh ugh, NO @ryaan_anthony. While PHP warnings can be ignored, they can not be safely ignore. Polluted error logs or error reporting turned down hides other, fatal errors. That is bad advice. – Alan Storm May 23 '16 at 18:23
11

The error you're seeing

Warning: Declaration of EbayEnterprise_MultipleCoupons_Model_Validator::_canProcessRule(Mage_SalesRule_Model_Rule $rule, Mage_Sales_Model_Quote_Address $address) should be compatible with Mage_SalesRule_Model_Validator::_canProcessRule($rule, $address) in /home/public_html/app/code/community/EbayEnterprise/MultipleCoupons/Model/Validator.php on line 15

Is a PHP error. At some point, someone (maybe you), added a EbayEnterprise_MultipleCoupons module to your Magento system. This module includes and uses a class named

EbayEnterprise_MultipleCoupons_Model_Validator

This class extends a core Magento class

Mage_SalesRule_Model_Validator

and redefines the _canProcessRule method. This is a standard, simple, object oriented programming technique. The programmers that created EbayEnterprise_MultipleCoupons wanted to (or needed to) reuse some code from the Mage_SalesRule_Model_Validator class.

The problem is, when they created the _canProcessRule method, they included type hints in their definition (Mage_SalesRule_Model_Rule and Mage_Sales_Model_Quote_Address)

_canProcessRule(Mage_SalesRule_Model_Rule $rule, Mage_Sales_Model_Quote_Address $address) 

but the original method (at least in Magento CE) does not have these type hints.

#File: app/code/core/Mage/SalesRule/Model/Validator.php
protected function _canProcessRule($rule, $address)
{
}

PHP has a strict coding standards mode that will warn you when these sorts of errors happen. In PHP a warning is a non-fatal error: it does not halt execution of your code.

The custom EbayEnterprise_MultipleCoupons module is not, as written, 100% compatible with a stock Magento CE system. If this is the module you installed, then that's your problem.

Its also possible your system has a core hack or local code pool override where the core file had these type hints. It's also possible these type hints exist in some version of Magento that the original EbayEnterprise_MultipleCoupons module was developed against. It's also possible the programmers of EbayEnterprise_MultipleCoupons created the module with these errors, and decided it was good enough to ship. Its also possible that your adding of some other module ended up calling code that wasn't called in your system, which has brought this error to light. i.e. the error may have been there for years, but your new module made it visible. Welcome to programming.

The best solution? Tell whomever gave you the EbayEnterprise_MultipleCoupons module that they need to give you a module that works without polluting your error logs.

Next best, and the way most Magento shops would handle this, create a copy of the EbayEnterprise_MultipleCoupons_Model_Validator class file in the local code pool (app/code/local/EbayEnterprise/MultipleCoupons/Model/Validator.php) and remove the type hints from that method. If you ever update the module in community, you will also need to update your class in local. You will probably forget to do this.

Finally, many developers will recommend you just turn down PHP's error reporting not to show warnings, since they're not really a problem. That's an awful solution, so I won't mention how to do it, but it's a solution you'll often see out in the wild, as its the quickest way to hide a visible error without spending the time to solve it.

|improve this answer|||||
  • What do you mean by "remove the type hints from that method" What are "type hints" I have several modules of your installed, thanks. – Freejoy May 26 '16 at 14:30
  • @Freejoy Type hints are the class names in front of of a method's arguments. – Alan Storm May 26 '16 at 14:50
  • You can't just comment the error out? – Freejoy May 26 '16 at 15:39
  • Don't get me wrong I don't normally suppress errors but I'm running the community edition and don't seem have these type hints. – Freejoy May 26 '16 at 15:46
  • @Freejoy "Comment the error out" meaning what, exactly? PHP doesn't have the ability to block a specific error, only classes of errors. Stopping classes of errors means you won't see other errors like this that might be causing unstable behavior. You're welcome to do whatever you like -- its your Magento system -- but suppressing errors of a certain type means you're creating a headache for whomever takes over the site next. – Alan Storm May 26 '16 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.