tmuras / moosh

Moosh
GNU General Public License v3.0
234 stars 177 forks source link

Add cache-edit-mapping and cache-add-redis-store for Moodle 405 #501

Open owngr opened 1 month ago

owngr commented 1 month ago

Related issue: https://github.com/tmuras/moosh/issues/500

I'm quite newby with PHP so it might not be the best solution.

cache-edit-mapping

Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in /var/www/html/lib/classes/session/redis.php on line 235 [10-Oct-2024 16:28:36 Europe/Berlin] Default exception handler: Setting up of redis session failed. Please notify the server administrator. Debug: Error code: redissessionhandlerproblem

!!! Setting up of redis session failed. Please notify the server administrator. !!!


Therefore I added the following code in order to avoid a login, I couldn't find a better solution:

```php
public function bootstrapLevel() {
  return self::$BOOTSTRAP_FULL_NO_ADMIN_CHECK;
}

cache-add-redis-store

Use 3 digit versions number

I started by naming the folder Moodle45 but still received errors because moosh was using Moodle310 cache-add-redis-store.

Moodle started using 3 digits number version for branch in version.php with Moodle 310.

Therefore, when I tried to use the 45 version it would pickup Moodle 310 as 310 > 45 as you can see here:

 /opt/moosh/moosh.php -v --no-user-check cache-add-redis-store --key-prefix="cache_" "redis" "$MAAS_REDIS_HOST"
Top Moodle dir: /var/www/html
Current working dir: /var/www/html
Relative Moodle dir:
Processing command option 'help''
Processing command option 'password''
Processing command option 'key-prefix''
'key-prefix' option is set on the command line to 'cache_'
Moodle version detected: 405
Command: add-redis-store (cache)
Options:
    help (): ''
    key-prefix (): 'cache_'
Arguments:
    redis redis-master
[10-Oct-2024 12:04:11 Europe/Berlin] PHP Warning:  require_once(/var/www/html/cache/locallib.php): Failed to open stream: No such file or directory in /opt/moosh/Moosh/Command/Moodle310/Cache/CacheAddRedisStore.php on line 37

Warning: require_once(/var/www/html/cache/locallib.php): Failed to open stream: No such file or directory in /opt/moosh/Moosh/Command/Moodle310/Cache/CacheAddRedisStore.php on line 37

The only way to make moosh pickup the right version was to refractor the whole numbering to start using 3 digit.

rimkov commented 3 weeks ago

we have the same problem, no moosh command works. i can work around the problem by commenting out the line $CFG->session_handler_class = '\core\session\redis'; in the config.php

moodle 4.5.0 php 8.1 moosh 1.14

benyovszky commented 2 weeks ago

Same here; all commands are failing. I do not want to add self::$BOOTSTRAP_FULL_NO_ADMIN_CHECK; for every command that I use, I need a most maintainable solution. moodle 4.5.0 php 8.2 moosh 1.21 and 1.24

Removing the config items means failing back to the standard session management, and that works, obviously.

I spent some hours to find a proper way to start a session from moosh, but already with the defined handler, in my case it is redis. No luck so far.