Upgrade from 3.5 to 3.7 -> exception in custom plugin

Upgrade from 3.5 to 3.7 -> exception in custom plugin

by Anze Pratnemer -
Number of replies: 5

I have written plugin that works on 3.5 Moodle.

I have installed fresh dev version of 3.7 Moodle and now when I try to run my plugin, I get expection:


    !!! Exception - syntax error, unexpected ')', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' !!!

Line that triggers that is in bold. I have gone through the release notes of both 3.6 and 3.7 and I cannot find a change why this would break.

Code:

namespace local_studissync\task;

defined('MOODLE_INTERNAL') || die();

class worker extends \core\task\scheduled_task {

public function execute() {

mtrace("Starting sync with Studis!");

$sync = new \local_studissync\sync();


Any advice how to go and solve this?

Average of ratings: -
In reply to Anze Pratnemer

Re: Upgrade from 3.5 to 3.7 -> exception in custom plugin

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Is the plugin's source code available somewhere in a public repository?

Average of ratings: Useful (1)
In reply to David Mudrák

Re: Re: Upgrade from 3.5 to 3.7 -> exception in custom plugin

by Anze Pratnemer -
Not really, its a custom plugin for syncing Moodle with our inhouse student information system..

This code snippet is from file worker.php, tree stucture is:

_plugin_root_/
--- classes/
------- cert/
------- task/worker.php
------- sync.php
--- db/
--- lang/
--- externallib.php
--- lib.php (empty)
--- settings.php
--- version.php

Is it possible, that error is returned from sync.php which is called in worker.php? How to debug that?
In reply to Anze Pratnemer

Re: Re: Re: Upgrade from 3.5 to 3.7 -> exception in custom plugin

by Anze Pratnemer -
Also:

sync.php starts with:
<?php
namespace local_studissync;
defined('MOODLE_INTERNAL') || die();

class sync{

public function do_sync(){


global $CFG, $DB;
require_once($CFG->dirroot. '/course/lib.php');
require_once($CFG->dirroot. '/user/lib.php');
require_once($CFG->dirroot. '/enrol/locallib.php');

require_once($CFG->libdir. '/coursecatlib.php');
require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');

and even if I return true right after the function do_sync() {, error still happens.

Did php 7.3 do something with class definitions?
In reply to Anze Pratnemer

Re: Re: Re: Re: Upgrade from 3.5 to 3.7 -> exception in custom plugin

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Did php 7.3 do something with class definitions?

Did you also move to PHP 7.3 at the same time as moving to Moodle 3.7?

Take a look at the PHP 7.3 tracker issue and see if any of the changes there are relevant to your plugin.

Average of ratings: Useful (1)
In reply to Mark Johnson

Re: Re: Re: Re: Re: Upgrade from 3.5 to 3.7 -> exception in custom plugin

by Anze Pratnemer -
Thank you both for help.

I admit, it was my fault. I pulled newish plugin file from dev machine, which had some unfinished stuff in the code sad

The culprit was inside instanced class, not in worker.php.