[OJS 3.2.1] Possible bug when reviewer submits review

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,

Hi @jp_ecancer,

That looks like a good resolution to me. Would you be willing to send it in via Github as a pull request? That file can be found here: https://github.com/pkp/pkp-lib/blob/stable-3_2_1/classes/reviewForm/ReviewFormResponseDAO.inc.php

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I see this is already fixed on the master branch.

Thanks,

@jp_ecancer

1 Like

Hi @jp_ecancer,

Thanks for the heads-up! This will be resolved in the next release from master, which is OJS/OMP/OPS 3.3.0, planned for Q4 this year.

Regards,
Alec Smecher
Public Knowledge Project Team