moodle-tool_mergeusers icon indicating copy to clipboard operation
moodle-tool_mergeusers copied to clipboard

Install error "Exception - Call to undefined method cache_disabled::check_lock_state()"

Open fernandezalerrt opened this issue 10 months ago • 9 comments

$version = 2022112800.07; // 20221128 = branching date YYYYMMDD - do not modify! $release = '4.1+ (Build: 20230105)'; // Human-friendly version name $branch = '401'; // This version's branch. PHP 8.2.5 AWS

fernandezalerrt avatar Apr 18 '24 16:04 fernandezalerrt

Hi!

Thanks for the feedback @fernandezalerrt .

Which version of the plugin are you using?

We are using this plugin in our production site without any error.

On https://moodle.org/plugins/tool_mergeusers/versions you can see a specific version for Moodle 4.1, and it is not the last version. Have you checked that? If you are using this git repo to get it, it is related to the branch MOODLE_401_STABLE of this repo.

If it still applies this error, please, enable developer debug level, and paste here the trace of the error.

Thanks,

Jordi

PD: I think you have contacted me privately on moodle.org. This issue is more relevant for this kind of thinkgs. Thanks again for contacting.

jpahullo avatar Apr 19 '24 07:04 jpahullo

Hi Thanks for the reply. Cache and upgrade problems with the database. It's working right now. Is there a way I can execute the plugin via API? Our principal users' database is in another web, I want to merge users in Moodle when I merge users in the principal database.

Thanks again

On Fri, Apr 19, 2024 at 3:22 AM Jordi Pujol-Ahulló @.***> wrote:

Hi!

Thanks for the feedback @fernandezalerrt https://github.com/fernandezalerrt .

Which version of the plugin are you using?

We are using this plugin in our production site without any error.

On https://moodle.org/plugins/tool_mergeusers/versions you can see a specific version for Moodle 4.1, and it is not the last version. Have you checked that? If you are using this git repo to get it, it is related to the branch MOODLE_401_STABLE of this repo.

If it still applies this error, please, enable developer debug level, and paste here the trace of the error.

Thanks,

Jordi

PD: I think you have contacted me privately on moodle.org. This issue is more relevant for this kind of thinkgs. Thanks again for contacting.

— Reply to this email directly, view it on GitHub https://github.com/jpahullo/moodle-tool_mergeusers/issues/265#issuecomment-2065924955, or unsubscribe https://github.com/notifications/unsubscribe-auth/BH5SYTIWWZIE4FQB7VK4MRTY6DA5BAVCNFSM6AAAAABGNST4H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVHEZDIOJVGU . You are receiving this because you were mentioned.Message ID: @.***>

fernandezalerrt avatar Apr 19 '24 11:04 fernandezalerrt

I got this error.

  1. Choose users to merge / ► 2. Confirm users to merge / ► 3. Merging results and log

Merged @.» (user ID = 10030) into @.» (user ID = 10029)

For further reference, these results are recorded in the log id 1. Some error occurred:

Exception thrown when merging: 'Error reading from database". Unknown column 'id' in 'field list' Trace: #0 /var/virtual/alerrt.org/moodle/lib/dml/moodle_read_slave_trait.php(293): moodle_database->query_end() #1 /var/virtual/ alerrt.org/moodle/lib/dml/mysqli_native_moodle_database.php(1278): mysqli_native_moodle_database->query_end() #2 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(295): mysqli_native_moodle_database->get_records_sql() #3 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(73): GenericTableMerger->get_records_to_be_updated() #4 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/mergeusertool.php(268): GenericTableMerger->merge() #5 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/mergeusertool.php(192): MergeUserTool->_merge() #6 /var/virtual/alerrt.org/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge() #7 {main}

Started merging at Friday, 19 April 2024, 6:42 AM Merge took 0 seconds

On Fri, Apr 19, 2024 at 7:33 AM Felipe Fernandez @.***> wrote:

Hi Thanks for the reply. Cache and upgrade problems with the database. It's working right now. Is there a way I can execute the plugin via API? Our principal users' database is in another web, I want to merge users in Moodle when I merge users in the principal database.

Thanks again

On Fri, Apr 19, 2024 at 3:22 AM Jordi Pujol-Ahulló < @.***> wrote:

Hi!

Thanks for the feedback @fernandezalerrt https://github.com/fernandezalerrt .

Which version of the plugin are you using?

We are using this plugin in our production site without any error.

On https://moodle.org/plugins/tool_mergeusers/versions you can see a specific version for Moodle 4.1, and it is not the last version. Have you checked that? If you are using this git repo to get it, it is related to the branch MOODLE_401_STABLE of this repo.

If it still applies this error, please, enable developer debug level, and paste here the trace of the error.

Thanks,

Jordi

PD: I think you have contacted me privately on moodle.org. This issue is more relevant for this kind of thinkgs. Thanks again for contacting.

— Reply to this email directly, view it on GitHub https://github.com/jpahullo/moodle-tool_mergeusers/issues/265#issuecomment-2065924955, or unsubscribe https://github.com/notifications/unsubscribe-auth/BH5SYTIWWZIE4FQB7VK4MRTY6DA5BAVCNFSM6AAAAABGNST4H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVHEZDIOJVGU . You are receiving this because you were mentioned.Message ID: @.***>

fernandezalerrt avatar Apr 19 '24 11:04 fernandezalerrt

IN lib/table/generictablemerger.php

$data = Array

( [toid] => 10030 [fromid] => 10029 [tableName] => adminpresets [userFields] => Array ( [userid] => userid )

)

I inserted a print/die in the script, in case it helps you. Thank you

On Fri, Apr 19, 2024 at 7:43 AM Felipe Fernandez @.***> wrote:

I got this error.

  1. Choose users to merge / ► 2. Confirm users to merge / ► 3. Merging results and log

Merged @.» (user ID = 10030) into @.» (user ID = 10029)

For further reference, these results are recorded in the log id 1. Some error occurred:

Exception thrown when merging: 'Error reading from database". Unknown column 'id' in 'field list' Trace: #0 /var/virtual/alerrt.org/moodle/lib/dml/moodle_read_slave_trait.php(293): moodle_database->query_end() #1 /var/virtual/ alerrt.org/moodle/lib/dml/mysqli_native_moodle_database.php(1278): mysqli_native_moodle_database->query_end() #2 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(295): mysqli_native_moodle_database->get_records_sql() #3 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(73): GenericTableMerger->get_records_to_be_updated() #4 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/mergeusertool.php(268): GenericTableMerger->merge() #5 /var/virtual/ alerrt.org/moodle/admin/tool/mergeusers/lib/mergeusertool.php(192): MergeUserTool->_merge() #6 /var/virtual/alerrt.org/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge() #7 {main}

Started merging at Friday, 19 April 2024, 6:42 AM Merge took 0 seconds

On Fri, Apr 19, 2024 at 7:33 AM Felipe Fernandez @.***> wrote:

Hi Thanks for the reply. Cache and upgrade problems with the database. It's working right now. Is there a way I can execute the plugin via API? Our principal users' database is in another web, I want to merge users in Moodle when I merge users in the principal database.

Thanks again

On Fri, Apr 19, 2024 at 3:22 AM Jordi Pujol-Ahulló < @.***> wrote:

Hi!

Thanks for the feedback @fernandezalerrt https://github.com/fernandezalerrt .

Which version of the plugin are you using?

We are using this plugin in our production site without any error.

On https://moodle.org/plugins/tool_mergeusers/versions you can see a specific version for Moodle 4.1, and it is not the last version. Have you checked that? If you are using this git repo to get it, it is related to the branch MOODLE_401_STABLE of this repo.

If it still applies this error, please, enable developer debug level, and paste here the trace of the error.

Thanks,

Jordi

PD: I think you have contacted me privately on moodle.org. This issue is more relevant for this kind of thinkgs. Thanks again for contacting.

— Reply to this email directly, view it on GitHub https://github.com/jpahullo/moodle-tool_mergeusers/issues/265#issuecomment-2065924955, or unsubscribe https://github.com/notifications/unsubscribe-auth/BH5SYTIWWZIE4FQB7VK4MRTY6DA5BAVCNFSM6AAAAABGNST4H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRVHEZDIOJVGU . You are receiving this because you were mentioned.Message ID: @.***>

fernandezalerrt avatar Apr 19 '24 11:04 fernandezalerrt

Hi,

Thanks for the feedback and the effort for providing it.

However, if it was caused by a cache issue during upgrade or installation, it is just that.

Regarding your important question:

Is there a way I can execute the plugin via API? Our principal users' database is in another web, I want to merge users in Moodle when I merge users in the principal database.

Yes, you can.

How? The answer is a bit longer than before, hehe.

It is documented on the README.md:

https://github.com/jpahullo/moodle-tool_mergeusers#command-line-script

And this is what we have implemented in our institution to have an unattended merging process every day.

The idea behind the Gathering interface is that it provides the list of merging actions to perform. You can implement it, in your case, for instance, accessing to an external database (infrastructure and firewalling issues are on your hands), or getting the list of merging actions from a REST API that you can get from the Moodle side. So, in summary, your Gathering implementation, say FernandezGathering is the reponsible to provide the list of action. The how? is what you have to implement in your new class.

Following the above example, you would have:

  1. A new file inside this plugin, in your Moodle (do not contribute it, if it is something specific for you), like admin/tool/mergeusers/lib/FernandezGathering.php.
  2. Add or edit the configuration file admin/tool/mergeusers/config/config.local.php with something like:
<?php

return array(

    // gathering tool
    'gathering' => 'FernandezGathering',
);
  1. Add the cli script admin/tool/mergeusers/cli/climerger.php into the crontab of your server, as often as you consider. We have it in our institution once a day, according to the rest of corporate processes.

And mainly, this is all! The big effort for you is to analyse if you can build the list of merging actions from a FernandezGathering.php from the Moodle side. And if so, implement it. When implementing it, given that the plugin expects user.ids, you will have to translate inside the FernandezGathering the external username/idnumber/whatever to a Moodle user.id, and provide the source id (to remove) and the target id (to keep).

As an example, we have implemented it in our institution by asking the list from an external database. So, it is possible. In that implementation, we also consider edge cases, like users not found yet on Moodle and so, informing why the merging action is not being performed right now. Actually, our implementation also consider a number of attempts to retry the merging actions. It is all in your hands. Here, the important thing is to keep the order of the merging action list. Since edge cases my arise, like from A to B, later B to C, and later C to A. These merging actions in a different order will produce a different result. In that case, the final user (the person with that username) will not get the whole Moodle content/activit/etc under its user profile or may not know which is the actual username to use each time.

Thanks for contacting,

Jordi

jpahullo avatar Apr 19 '24 13:04 jpahullo

Thank you for your explanation. I'll try and let you know Have a great weekend

On Fri, Apr 19, 2024 at 9:01 AM Jordi Pujol-Ahulló @.***> wrote:

Hi,

Thanks for the feedback and the effort for providing it.

However, if it was caused by a cache issue during upgrade or installation, it is just that.

Regarding your important question:

Is there a way I can execute the plugin via API? Our principal users' database is in another web, I want to merge users in Moodle when I merge users in the principal database.

Yes, you can.

How? The answer is a bit longer than before, hehe.

It is documented on the README.md:

https://github.com/jpahullo/moodle-tool_mergeusers#command-line-script

And this is what we have implemented in our institution to have an unattended merging process every day.

The idea behind the Gathering interface is that it provides the list of merging actions to perform. You can implement it, in your case, for instance, accessing to an external database (infrastructure and firewalling issues are on your hands), or getting the list of merging actions from a REST API that you can get from the Moodle side. So, in summary, your Gathering implementation, say FernandezGathering is the reponsible to provide the list of action. The how? is what you have to implement in your new class.

Following the above example, you would have:

  1. A new file inside this plugin, in your Moodle (do not contribute it, if it is something specific for you), like admin/tool/mergeusers/lib/FernandezGathering.php.
  2. Add or edit the configuration file admin/tool/mergeusers/config/config.local.php with something like:
'FernandezGathering', ); 3. Add the cli script admin/tool/mergeusers/cli/climerger.php into the crontab of your server, as often as you consider. We have it in our institution once a day, according to the rest of corporate processes. And mainly, this is all! The big effort for you is to analyse if you can build the list of merging actions from a FernandezGathering.php from the Moodle side. And if so, implement it. When implementing it, given that the plugin expects user.ids, you will have to translate inside the FernandezGathering the external username/idnumber/whatever to a Moodle user.id, and provide the source id (to remove) and the target id (to keep). As an example, we have implemented it in our institution by asking the list from an external database. So, it is possible. In that implementation, we also consider edge cases, like users not found yet on Moodle and so, informing why the merging action is not being performed right now. Actually, our implementation also consider a number of attempts to retry the merging actions. It is all in your hands. Here, the important thing is to keep the order of the merging action list. Since edge cases my arise, like from A to B, later B to C, and later C to A. These merging actions in a different order will produce a different result. In that case, the final user (the person with that username) will not get the whole Moodle content/activit/etc under its user profile or may not know which is the actual username to use each time. Thanks for contacting, Jordi — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned.Message ID: ***@***.***>

fernandezalerrt avatar Apr 19 '24 13:04 fernandezalerrt

The same to you @fernandezalerrt !

jpahullo avatar Apr 19 '24 13:04 jpahullo

By the way, @fernandezalerrt ,

The last, but not the least: a merging action is an idempotent operation. That means that if you repeat the same operation a second time, a third time, from the same two user ids, the result will be the same. This is why we added retries on our Gathering implementation. The only difference my appear on the actions being done inside every merging action: while the first one will contain a bunch of operations, the second one and the others, should contain almost nothing.

Thanks,

Jordi

jpahullo avatar Apr 19 '24 13:04 jpahullo

Thanks for the tip!

On Fri, Apr 19, 2024, 09:15 Jordi Pujol-Ahulló @.***> wrote:

By the way, @fernandezalerrt https://github.com/fernandezalerrt ,

The last, but not the least: a merging action is an idempotent operation. That means that if you repeat the same operation a second time, a third time, from the same two user ids, the result will be the same. This is why we added retries on our Gathering implementation. The only difference my appear on the actions being done inside every merging action: while the first one will contain a bunch of operations, the second one and the others, should contain almost nothing.

Thanks,

Jordi

— Reply to this email directly, view it on GitHub https://github.com/jpahullo/moodle-tool_mergeusers/issues/265#issuecomment-2066559484, or unsubscribe https://github.com/notifications/unsubscribe-auth/BH5SYTJBAPKIOTH7QOJ5NT3Y6EKH3AVCNFSM6AAAAABGNST4H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWGU2TSNBYGQ . You are receiving this because you were mentioned.Message ID: @.***>

fernandezalerrt avatar Apr 19 '24 13:04 fernandezalerrt