0

I recently moved one of my sites to a new dedicated server running the latest version of PHP. In my php-based Knowledgebase section of the site, I am getting the following error:

Strict Standards: Declaration of API_RATING::multiDelete() should be compatible with API::multiDelete($ids = 0) in /home/givebrad/public_html/kb/lib/api/class.rating.php on line 156

Line 156 is the last closing } at the bottom of the file. Below is the code for class-rating.php. Can anyone help me out to figure out how to fix this?

<?php
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'class.api.php');

class API_RATING extends API
{
    var $rateid = 0;
    var $questionid = 0;
    var $ip = '';
    var $ratedat = '';

    var $fields = array (
        'rateid',
        'questionid',
        'ip',
        'ratedat',
        'ratingemail',
        'ratingmessage'
    );

    var $pk = 'rateid';

    /**
    * create
    * create a new rating in the database
    *
    * @return bool was the creation successful ?
    */
    function create()
    {
        $_POST['ratedat'] = date('Y-m-d H:i:s');
        $_POST['ip'] = $_SERVER['REMOTE_ADDR'];
        return parent::create();
    }

    /**
    * multiDelete
    * Delete multiple rating ids. Update each associated question.
    *
    * @return bool was the delete successful?
    */
    function multiDelete($ids) {

        //Get the question ids
        $objArray = $this->loadMultiByPK($ids);

        foreach ($objArray as $rateObj) {
            $questionObj = new API_QUESTION(); 
            $questionObj->load($rateObj->questionid);

            $questionObj->negvotes--;
            $questionObj->score -= SCORE_MODIFIER;

            $questionObj->updateField("negvotes", $questionObj->negvotes);
            $questionObj->updateField("score", $questionObj->score);
        }           

        //Delete from the main table
        if (!parent::multiDelete($ids)) {
            return false;
        }

        return true;
    }

    /**
    * validate_rateid
    *
    * Ensure the rate id is a pos int
    *
    * @param string $var
    *
    * @return bool
    */
    function validate_rateid($var)
    {
        return $this->is_positive_int($var);
    }

    /**
    * validate_questionid
    *
    * Ensure the questionid is pos int
    *
    * @return bool
    */
    function validate_questionid($var)
    {
        return $this->is_positive_int($var);
    }

    /**
    * validate_ip
    *
    * Ensure the ip is an ipv4 address
    *
    * @param $var the ip to validate
    *
    * @return bool
    */
    function validate_ip($var)
    {
        return $this->is_ip($var);
    }

    /**
    * validate_ratedat
    *
    * Ensure the rated at date is in the standard date format
    *
    * @param string $var
    *
    * @return bool
    */
    function validate_ratedat($var)
    {
        return $this->is_standard_date($var);
    }

    /**
    * validate_email
    *
    * Ensure the email address for this rate entry is valid.
    *
    * @param string $var
    *
    * @return bool
    */
    function validate_ratingemail(&$var)
    {
        if ((trim($var) == "") || (trim($var) == GetLang("WhyUnhelpfulEmail"))) {
            $var = "";
            return true;
        } else {
            return is_email_address($var);
        }
    }   

    /**
    * validate_ratingmessage
    *
    * Ensure there is a message and its not blank.
    *
    * @param string $var
    *
    * @return bool
    */
    function validate_ratingmessage(&$var)
    {
        if (strlen(trim($var)) > 250) {
            $var = substr(trim($var),0,250);
            return true;
        } else {
            return (trim($var) != "");
        }
    }
}

?>

Rob
  • 33
  • 3
  • 8
  • There isn’t much to figure out – your method signature is `($id)`, whereas the API class you are inheriting from has its method’s parameters defined as `($ids = 0)`. So just adapt your method to set that default value as well, so that the signatures match again. – CBroe Oct 07 '13 at 12:08

1 Answers1

0

This function :

function multiDelete($ids) {

Should be identic with it's parent function, find out the same function in class API, the nums, default value and type of the params should be same;

I asked this before, Strict Standards: Declaration of ' ' should be compatible with ' '

Community
  • 1
  • 1
egig
  • 4,370
  • 5
  • 29
  • 50