compilatio / moodle-plagiarism_compilatio

Compilatio.net plagiarism plugin for Moodle
4 stars 9 forks source link

Error while upgrading to 2.7 version #93

Open cperves opened 1 year ago

cperves commented 1 year ago

Hello, I tried to upgrade to 2.7 version from 2.6.15 on a 4.1 Moodle with php 8.1 On my local instance Compilatiois not enabled (dev version) while upgrading I had the following error

-->plagiarism_compilatio
<div class="box py-3 generalbox boxaligncenter"><p>Compilatio tables structure has been checked.</p></div>Default exception handler: Erreur d'écriture vers la base de données Debug: ERROR:  null value in column "value" violates not-null constraint
DETAIL:  Failing row contains (22, account_expire_on, null).
INSERT INTO mdl_plagiarism_compilatio_data (name,value) VALUES($1,$2) RETURNING id
[array (
  'name' => 'account_expire_on',
  'value' => NULL,
)]
Error code: dmlwriteexception
* line 497 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
* line 341 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_slave_query_end()
* line 1132 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
* line 1180 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
* line 2561 of /plagiarism/compilatio/lib.php: call to pgsql_native_moodle_database->insert_record()
* line 1237 of /plagiarism/compilatio/lib.php: call to compilatio_update_account_expiration_date()
* line 246 of /plagiarism/compilatio/db/upgrade.php: call to compilatio_update_meta()
* line 784 of /lib/upgradelib.php: call to xmldb_plagiarism_compilatio_upgrade()
* line 1953 of /lib/upgradelib.php: call to upgrade_plugins()
* line 202 of /admin/cli/upgrade.php: call to upgrade_noncore()

!!! Erreur d'écriture vers la base de données !!!
!! ERROR:  null value in column "value" violates not-null constraint
DETAIL:  Failing row contains (22, account_expire_on, null).
INSERT INTO mdl_plagiarism_compilatio_data (name,value) VALUES($1,$2) RETURNING id
[array (
  'name' =&gt; 'account_expire_on',
  'value' =&gt; NULL,
)]
Error code: dmlwriteexception !!
!! Stack trace: * line 497 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database-&gt;query_end()
* line 341 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database-&gt;read_slave_query_end()
* line 1132 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database-&gt;query_end()
* line 1180 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database-&gt;insert_record_raw()
* line 2561 of /plagiarism/compilatio/lib.php: call to pgsql_native_moodle_database-&gt;insert_record()
* line 1237 of /plagiarism/compilatio/lib.php: call to compilatio_update_account_expiration_date()
* line 246 of /plagiarism/compilatio/db/upgrade.php: call to compilatio_update_meta()
* line 784 of /lib/upgradelib.php: call to xmldb_plagiarism_compilatio_upgrade()
* line 1953 of /lib/upgradelib.php: call to upgrade_plugins()
* line 202 of /admin/cli/upgrade.php: call to upgrade_noncore()
 !!

I correct this by patching compilatio/lib.php

function compilatio_update_account_expiration_date() {

    global $DB;
    $expirationdate = compilatio_get_account_expiration_date();
    if (empty($expirationdate)) {
      return;

if (empty($expirationdate)) replace if ($expirationdate === false))

cperves commented 1 year ago

After this I finally update but hafd the following warning

<div class="box py-3 generalbox boxaligncenter"><p>Compilatio tables structure has been checked.</p></div>PHP Warning:  foreach() argument must be of type array|object, null given in /var/www/moodle_layerunistra404/plagiarism/compilatio/lib.php on line 2591

Warning: foreach() argument must be of type array|object, null given in /var/www/moodle_layerunistra404/plagiarism/compilatio/lib.php on line 2591
PHP Warning:  Trying to access array offset on value of type bool in /var/www/moodle_layerunistra404/plagiarism/compilatio/helper/ws_helper.php on line 49

Warning: Trying to access array offset on value of type bool in /var/www/moodle_layerunistra404/plagiarism/compilatio/helper/ws_helper.php on line 49
cperves commented 1 year ago

Hello, anybody on this issue?

benoitcompilatio commented 1 year ago

Hello,

I've fixed the null value insert that was causing an error in update_account_expiration_date on 2.7.1 branch (commit)

For the foreach warning I don't see any foreach on line 2591, can you give us more details to fix this?

cperves commented 11 months ago

Sorry for the late response but I didn't see issue notification I think the wrning is due to if ($news !== false) { in lib.php in compilatio_update_news function , same problem that with $expirationdate You need to change it by if(!empty(($news)){ Regards Céline