3

I got this notice when I changed a Joomla website from PHP 5.6 to PHP7.2

"Only variables should be passed by reference in ... on line 116" The second line is line 116

    if($this->isViewExcluded($article)) {
        if($this->isArticleExcluded(JRequest::getInt('id', 0))) {
            $this->createButton($article);

Same for line 257 The third line beneath

function getArticleLink(&$article)
{
        $u =& JFactory::getURI();
        return $u->toString();
}

I read Replacing JRequest (deprecated) with JInput when I got the notice and tried a lot with the solution given on that page (and other pages), but unfortunately no success.

Does anyone has a solution to make this work in PHP7.2 ?

2

Because the function argument contains a & at the beginning, it requires a variable to be passed by reference rather than referencing an object value directly.

So you'll need to replace this:

if ($this->isArticleExcluded(JRequest::getInt('id', 0))) {

}

with this:

$id = JFactory::getApplication()->input->get('id');

if ($this->isArticleExcluded($id)) {

}

Also, you can remove the & before JFactory

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.