Hi,
We are working on OJS 3.2.1-0 from a tarball using PHP 7.2.
When a reviewer submits their review the following PHP Notice appears several times in the OJS error_log:
PHP Notice: Only variables should be passed by reference in /var/www/html/lib/pkp/classes/reviewForm/ReviewFormResponseDAO.inc.php on line 74
The code which is causing the notice is the call to $this->convertToDB
. Here is the code from pkp lib master on github:
function insertObject(&$reviewFormResponse) {
$responseValue = $this->convertToDB($reviewFormResponse->getValue(), $reviewFormResponse->getResponseType());
$this->update(
'INSERT INTO review_form_responses
(review_form_element_id, review_id, response_type, response_value)
VALUES
(?, ?, ?, ?)',
array(
$reviewFormResponse->getReviewFormElementId(),
$reviewFormResponse->getReviewId(),
$reviewFormResponse->getResponseType(),
$responseValue
)
);
}
The second argument should be a variable.
As it stands, if $reviewFormResponse->getResponseType()
is null
, then DAO::convertToDB() will fail to set it to 'string'
, and it will remain null
. In that case, the type
which gets entered into the database will not be the default 'string'
.
Assuming this is not the desired behaviour, a workaround would be:
function insertObject(&$reviewFormResponse) {
$responseType = $reviewFormResponse->getResponseType();
$responseValue = $this->convertToDB($reviewFormResponse->getValue(), $responseType);
$this->update(
'INSERT INTO review_form_responses
(review_form_element_id, review_id, response_type, response_value)
VALUES
(?, ?, ?, ?)',
array(
$reviewFormResponse->getReviewFormElementId(),
$reviewFormResponse->getReviewId(),
$responseType,
$responseValue
)
);
}
Regards,