Upgrade from 3.5 to 3.7 -> exception in custom plugin

Upgrade from 3.5 to 3.7 -> exception in custom plugin

Anze Pratnemer-mit -
Antal besvarelser: 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?

Gennemsnitsbedømmelse: -
I svar til Anze Pratnemer

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

David Mudrák-mit -
Core developers-ip assinga Documentation writers-ip assinga Moodle HQ-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga Plugins guardians-ip assinga Testers-ip assinga Translators-ip assinga

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

I svar til David Mudrák

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

Anze Pratnemer-mit -
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?
I svar til Anze Pratnemer

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

Anze Pratnemer-mit -
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?
I svar til Anze Pratnemer

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

Mark Johnson-mit -
Core developers-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga
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.

I svar til Mark Johnson

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

Anze Pratnemer-mit -
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.