Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Create New Role with "Incorrect role short name" #26

Open
jimsihk opened this issue Mar 13, 2023 · 25 comments · Fixed by #27
Open

Unable to Create New Role with "Incorrect role short name" #26

jimsihk opened this issue Mar 13, 2023 · 25 comments · Fixed by #27

Comments

@jimsihk
Copy link
Contributor

jimsihk commented Mar 13, 2023

Hi,

When defining new roles, it will always rejected by "Incorrect role short name". I tried using the docker-compose.yaml with moodle 4.0 version up to the latest are still facing the same problem.

For comparison, I tried picking the bitnami stack from GCP and it works without this issue. Do you think is related to NGINX and MariaDB? I don't have a chance yet to test the bitnami moodle container though.

I also notice that there is an issue logged on official tracker as MDL-77369 and the issue seems related to container only.

Any thought?

@erseco
Copy link
Owner

erseco commented Mar 13, 2023

Is possible that the problem is caused because we are using postgresql instead of mariadb, can you please check if with MariaDB it works?

@jimsihk
Copy link
Contributor Author

jimsihk commented Mar 13, 2023

Tried with mariadb, unfortunately, still the same error, below the docker-compose.yml fyi:

version: '2'
services:

  mariadb:
    image: mariadb:latest
    restart: unless-stopped
    environment:
      - MARIADB_RANDOM_ROOT_PASSWORD=yes
      - MARIADB_PASSWORD=moodle
      - MARIADB_USER=moodle
      - MARIADB_DATABASE=moodle
    volumes:
      - mariadb:/var/lib/mariadb/data

  moodle:
    image: erseco/alpine-moodle:4.1.1
    restart: unless-stopped
    environment:
      - LANG=en_US.UTF-8
      - LANGUAGE=en_US:en
      - SITE_URL=http://localhost
      - DB_TYPE=mariadb
      - DB_HOST=mariadb
      - DB_PORT=3306
      - DB_NAME=moodle
      - DB_USER=moodle
      - DB_PASS=moodle
      - DB_PREFIX=mdl_
      - SSLPROXY=false
      - [email protected]
      - MOODLE_LANGUAGE=en
      - MOODLE_SITENAME=New-Site
      - MOODLE_USERNAME=moodleuser
      - MOODLE_PASSWORD=PLEASE_CHANGEME
      - SMTP_HOST=smtp.gmail.com
      - SMTP_PORT=587
      - [email protected]
      - SMTP_PASSWORD=your_password
      - SMTP_PROTOCOL=tls
      - MOODLE_MAIL_NOREPLY_ADDRESS=noreply@localhost
      - MOODLE_MAIL_PREFIX=[moodle]
    ports:
      - 80:8080
    volumes:
      - moodledata:/var/www/moodledata
      - moodlehtml:/var/www/html
    depends_on:
      - mariadb

volumes:
  mariadb: null
  moodledata: null
  moodlehtml: null

@lupa18
Copy link

lupa18 commented Mar 13, 2023

I think is a moodle error and I am who opened MDL-77369. Please vote, watch or add comment there 😃

@jimsihk
Copy link
Contributor Author

jimsihk commented Mar 13, 2023

That is what I doubt actually. I did tried a 4.0 GCP Marketplace stack (not docker) and there is no issue, but the same version on docker faces the issue.

Also, not sure if help, I tried moosh 0.39 and it could create new roles normally from command line (might be a workaround for now?).

@lupa18 have you bypassed the issue?

@lupa18
Copy link

lupa18 commented Mar 14, 2023

@jimsihk I'm still waiting :-/

@jimsihk
Copy link
Contributor Author

jimsihk commented Mar 14, 2023

I tried to set PHP max_input_vars to even higher at 100000 but seems not related.

@erseco
Copy link
Owner

erseco commented Mar 14, 2023

I was checking if was problem with the PHP version (8.0) and the moodle version but seems is not related

I was debugging and seems the root problem can be in the https://github.com/moodle/moodle/blob/master/admin/roles/classes/define_role_table_basic.php file or in the https://github.com/moodle/moodle/blob/master/admin/roles/define.php but no idea on what is happening

By the way I setted up a new upstream version (4.1.2+) and PHP 8.1 but the problem persists, I will continue testing it, any news I will write here

@jimsihk
Copy link
Contributor Author

jimsihk commented Mar 23, 2023

Unfortunately, I tried with PHP8.1 and 4.1.2 still the same.

@lupa18
Copy link

lupa18 commented Mar 23, 2023

Please @jimsihk go to moodle issue tracker and comment my issue to see if can we move it.

Thanks!

@erseco
Copy link
Owner

erseco commented Mar 24, 2023

Added a message to move this!

@jimsihk
Copy link
Contributor Author

jimsihk commented Mar 29, 2023

I managed to test the bitnami docker but it works, so it seems not really related to Moodle code itself?

Would that be related to Nginx that we are using but bitnami is using Apache?

version: '2'
services:

  postgres:
    image: postgres:alpine
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=moodle
      - POSTGRES_USER=moodle
      - POSTGRES_DB=moodle
    volumes:
      - postgres:/var/lib/postgresql/data

  moodle:
    image: bitnami/moodle
    restart: unless-stopped
    environment:
      - MOODLE_DATABASE_TYPE=pgsql
      - MOODLE_DATABASE_HOST=postgres
      - MOODLE_DATABASE_PORT_NUMBER=5432
      - MOODLE_DATABASE_USER=moodle
      - MOODLE_DATABASE_PASSWORD=moodle
      - MOODLE_DATABASE_NAME=moodle
    ports:
      - 80:8080
    volumes:
      - moodledata:/var/www/moodledata
      - moodlehtml:/var/www/html
    depends_on:
      - postgres

volumes:
  postgres: null
  moodledata: null
  moodlehtml: null

@jimsihk
Copy link
Contributor Author

jimsihk commented Apr 7, 2023

As also mentioned in the Moodle tracker, the issue is caused by the incompatible version of iconv in Alpine (which seems to be a well-known problem) and that's why Bitnami's work because it is using Debian.

The line of code with problem: https://github.com/moodle/moodle/blob/1d863c338ac6ace8e6b945f0e2c49753acfdb837/lib/classes/text.php#L351
Error message: NOTICE: PHP message: PHP Warning: iconv(): Wrong encoding, conversion from "utf-8" to "ASCII//TRANSLIT//IGNORE" is not allowed in /var/www/html/lib/classes/text.php

One of the workaround could be replacing iconv with gnu-libiconv but need pointing to an older version as mentioned in docker-library/php#240 (comment):

RUN apk add gnu-libiconv=1.15-r3 --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ --allow-untrusted
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

Another way could be exploring to switch the base image to php:fpm-alpine3.17 which built PHP using the gnu-libiconv as mentioned in docker-library/php#1264

@erseco
Copy link
Owner

erseco commented Apr 7, 2023

Hi Jim,

Thank you for the detailed research on this issue! It's great that you've identified the cause of the problem and provided potential workarounds. I agree that sticking with the Alpine version is preferable, and I appreciate your suggestion to use gnu-libiconv.

Regarding the version mentioned in the linked messages, it's true that they refer to gnu-libiconv-1.16-r0. However, as you've pointed out, the Alpine 3.17 repository has the 1.17-r0 version, which could potentially contain a fix for this issue. It's worth trying out the newer version and see if it resolves the problem.

I'll implement these changes and test if the updated configuration works as expected. If everything goes well, we should have a functional Alpine-based solution. I'll keep you updated on the progress.

Once again, thanks for your valuable input and suggestions!

Best regards,

@jimsihk
Copy link
Contributor Author

jimsihk commented Apr 7, 2023

I tried gnu-libiconv=1.15-r3 does work, but higher version seems missing something or just not match with PHP8+. Let's see if any other options.

jimsihk added a commit to jimsihk/alpine-php-nginx that referenced this issue Apr 8, 2023
@jimsihk
Copy link
Contributor Author

jimsihk commented Apr 8, 2023

Considering it is a Alpine related issue instead of just Moodle, I tried to apply a quick fix on the base image and tested working, see if any suggestion (May need to cherry pick the commit for PR).

jimsihk added a commit to jimsihk/alpine-php-nginx that referenced this issue Apr 8, 2023
erseco added a commit that referenced this issue Apr 8, 2023
@erseco erseco closed this as completed in #27 Apr 8, 2023
erseco added a commit that referenced this issue Apr 8, 2023
Quick-and-dirty fix for issue #26 with gnu-libiconv
@erseco
Copy link
Owner

erseco commented Dec 20, 2023

Hi @jimsihk
Thanks for your contribution in resolving the gnu-libiconv compatibility issue we experienced with Moodle. With the recent release of Alpine 3.19, I wanted to follow up and ask if you're aware of any updates regarding the gnu-libiconv issue in this new version of Alpine. Your insights would be greatly appreciated as we continue to ensure smooth functionality.

Best regards.

@erseco erseco reopened this Dec 20, 2023
@jimsihk
Copy link
Contributor Author

jimsihk commented Dec 21, 2023

Tried to search around, seems only PHP 8.3 has applied a fix on it. Not sure if the community agreed to apply to PHP 8.2 as well.

Reference: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15114#note_362481

erseco added a commit that referenced this issue Dec 21, 2023
@erseco
Copy link
Owner

erseco commented Dec 21, 2023

Thanks for the reference! Based on this, I've created a new php83 branch/tag, which has successfully passed the CI pipeline. I'm currently in the process of debugging to ensure everything is working seamlessly. If all goes well, this update will be ready to merge for the upcoming Moodle 4.3.2 release. Fingers crossed! 🤞

@jimsihk
Copy link
Contributor Author

jimsihk commented Dec 22, 2023

That would be good! But Moodle official support on PHP 8.3 would be on Moodle 4.4 onwards, shall we wait?

https://moodledev.io/general/development/policies/php#php-83

@erseco
Copy link
Owner

erseco commented Dec 22, 2023

Thank you for pointing this out! Given that Moodle's official support for PHP 8.3 is slated to begin with Moodle 4.4, it does seem prudent to wait before implementing these changes. In light of this information, I will close the current issue and note in PR #58 that we should hold off until PHP 8.3 receives official support, hopefully in Moodle 4.4 as indicated.

This approach ensures our alignment with Moodle's official development and support policies, maintaining stability and compatibility for our users. I appreciate your input and look forward to adapting our environment in line with Moodle's future updates.

Thanks for your help!

@erseco erseco closed this as completed Dec 22, 2023
@jimsihk
Copy link
Contributor Author

jimsihk commented Apr 17, 2024

I just had a try with Moodle 4.4rc1 with PHP 8.3, unfortunately the error still happened. I have read again the alpine issue thread and it seems I have overlooked and the commit is NOT yet merged to the main. Guess we still need to stick to the dirty fix for now.

@erseco erseco reopened this Apr 17, 2024
@erseco
Copy link
Owner

erseco commented Apr 17, 2024

Hi @jimsihk, thank you for bringing this to our attention! I will keep this issue open and monitor it until the release of Moodle 4.5. Please let us know if there are any updates or changes in the meantime. :)

@erseco
Copy link
Owner

erseco commented Oct 19, 2024

Hi @jimsihk,

I hope you're doing well. I wanted to check in and ask if you've had a chance to test Moodle 4.5.0 and, if so, whether you know if the issue with iconv has been resolved.
Let me know how it’s going!

Best,
Ernesto

@jimsihk
Copy link
Contributor Author

jimsihk commented Oct 19, 2024

I haven't tried but since the issue is caused by iconv on alpine, it is still pending to fix. See https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/61689.

@erseco
Copy link
Owner

erseco commented Oct 19, 2024

Ok, let's wait so, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants