Output renderer issue

Output renderer issue

by Luis Ibhiabor -
Number of replies: 5

Hello Folks,

Please I was wondering if anyone has had this type of error message come up on a moodle site without any changes made to it.

"Parse error: syntax error, unexpected '[' in /usr/local/apache2/htdocs/mysite-moodle/lib/outputrenderers.php on line 110".

I just want to be sure first before making attempts to check the code in the renderer.php page.

Any help will be appreciated please.

Regards

Average of ratings: -
In reply to Luis Ibhiabor

Re: Outputrenderers issue

by Luis Ibhiabor -

Hello Folks,

Users are unable to log onto our website. We have a problem with the outputrenderer.php file.

Our moddle site was working well on a fresh installation of moodle 3.0. Users didn't have any problem logging in. No changes were made to it at any time and everything had been runing well. Suddenly, when we visit the site (http://kassop.nuguide-vle.com/), we only get the error message below.

"Parse error: syntax error, unexpected '[' in /usr/local/apache2/htdocs/mywebsite-moodle/lib/outputrenderers.php on line 110"

In my attempt to fix the error, I opened the outputrenderers.php and line 110 has the code below.

"'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));"

My php text editor actually highlights that line in red.

Could someone advise me on what to do to resolve this issue, please?

Your help will be very much appreciated.


In reply to Luis Ibhiabor

Re: Outputrenderers issue

by Ken Task -
Picture of Particularly helpful Moodlers

In looking at the code of that file on a functioning system, one sees the following:

'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));

Note the difference in yours above ... yours begins with a " then a tick '.

Yours also ends with a "

Unless you posted in italics the line and the forum editor added the whole line enclosed in ""'s.

Syntax error indicates a mis-match   The ['s should be there, but because of the "'s surrounding the entire line PHP objects.

So if your code has " at the beginning of that line and an enclosing " at the end, remove those characters and save the file.

Total guess of course.

'spirit of sharing', Ken



In reply to Luis Ibhiabor

Re: Outputrenderers issue

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It looks like you are using a version of PHP that is so old that it does not recognise the array literal syntax (  [1, 2, 3] ) that was added in PHP 5.4.

Moodle has required at least PHP 5.4 since the Moodle 2.7 release, and the environment check will prevent it from installing on older PHP versions.

So, probably a change was made to your side: someone changed the version of PHP being used to a very old one. That seems very strange.

In reply to Tim Hunt

Re: Outputrenderers issue

by Luis Ibhiabor -

Thanks everyone for your responses and suggestions. The problem has now been resolved.

Those quotes and italics were added by me after I copied the line.

Tim, you are perfectly right.

We tried to fix this issue "It looks like you are using a version of PHP that is so old that it does not recognise the array literal syntax (  [1, 2, 3] ) that was added in PHP 5.4."

In the process, the quote below was apparent.

"...So, probably a change was made to your side: someone changed the version of PHP being used to a very old one. That seems very strange."

That was exactly what happened.  The hosting company did something wrong and unprofessional without informing us about it. Our sites were strangely running PHP 5.3. It took us a lot of effort and previous tickets to prove it to them that our server had been running on PHP 5.4 and that was why we were able to run moodle 3.0 before everything went wrong with all our sites running it.

Now all our moodle sites are running fine again as they have changed it to PHP 5.4.26.

Once again, thanks to everyone.