BOINC / boinc

Open-source software for volunteer computing and grid computing.
https://boinc.berkeley.edu
GNU Lesser General Public License v3.0
2.02k stars 447 forks source link

PHP 8 deprecation warnings/errors in periodic tasks #4779

Open gchilders opened 2 years ago

gchilders commented 2 years ago

Thanks again for the quick work on these. The web pages look good now as far as I see. Turning to the periodic tasks, I see two with issues:

delete_spammers.php: Deprecated: Function strftime() is deprecated in /home/boincadm/projects/nfs/html/ops/delete_spammers.php on line 464

team_import.php: Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/boincadm/projects/nfs/html/ops/team_import.php on line 51 Processing BOINC Synergy @gmail.com case 1 updating PHP Fatal error: Uncaught mysqli_sql_exception: Incorrect string value: '\xE2\xAD\x90\xE2\xAD\x90...' for column 'description' at row 1 in /home/boincadm/projects/nfs/html/inc/db_conn.inc:69 Stack trace:

0 /home/boincadm/projects/nfs/html/inc/db_conn.inc(69): mysqli->query()

1 /home/boincadm/projects/nfs/html/inc/db_conn.inc(176): DbConn->do_query()

2 /home/boincadm/projects/nfs/html/inc/boinc_db.inc(262): DbConn->update()

3 /home/boincadm/projects/nfs/html/ops/team_import.php(124): BoincTeam->update()

4 /home/boincadm/projects/nfs/html/ops/team_import.php(247): update_team()

5 /home/boincadm/projects/nfs/html/ops/team_import.php(284): handle_team()

6 /home/boincadm/projects/nfs/html/ops/team_import.php(291): main()

7 {main}

thrown in /home/boincadm/projects/nfs/html/inc/db_conn.inc on line 69

davidpanderson commented 2 years ago

The "description" field of one of the BOINC-wide teams (BOINC Synergy) contained what looked like garbage characters. I cleaned these up; please try team_import.php again

gchilders commented 2 years ago

Got further, but here's an issue with SETI@Taiwan:

Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/boincadm/projects/nfs/html/ops/team_import.php on line 51 Processing SETI@Taiwan �x�W�ζ� redacted@gmail.com PHP Fatal error: Uncaught mysqli_sql_exception: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,COERCIBLE) for operation '=' in /home/boincadm/projects/nfs/html/inc/db_conn.inc:69 Stack trace:

0 /home/boincadm/projects/nfs/html/inc/db_conn.inc(69): mysqli->query()

1 /home/boincadm/projects/nfs/html/inc/db_conn.inc(116): DbConn->do_query()

2 /home/boincadm/projects/nfs/html/inc/db_conn.inc(131): DbConn->lookup_fields()

3 /home/boincadm/projects/nfs/html/inc/boinc_db.inc(270): DbConn->lookup()

4 /home/boincadm/projects/nfs/html/inc/boinc_db.inc(275): BoincTeam::lookup()

5 /home/boincadm/projects/nfs/html/ops/team_import.php(234): BoincTeam::lookup_name()

6 /home/boincadm/projects/nfs/html/ops/team_import.php(284): handle_team()

7 /home/boincadm/projects/nfs/html/ops/team_import.php(291): main()

8 {main}

thrown in /home/boincadm/projects/nfs/html/inc/db_conn.inc on line 69

davidpanderson commented 2 years ago

I fixed the first warning.

The MYSQL problem is outside of my expertise; maybe someone else can figure it out.

AenBleidd commented 2 years ago

This looks similar to this issue: https://github.com/BOINC/boinc/issues/1503

gchilders commented 2 years ago

I think there's a larger underlying issue with the collation used in the database, but for now to circumvent the issue I changed boinc_db.inc line 275 to return self::lookup("name='$name' COLLATE utf8mb4_0900_ai_ci");

This gets me to Processing Centro Meteorologico Lombardo - Italy redacted@email case 1 updating PHP Fatal error: Uncaught mysqli_sql_exception: Incorrect string value: '\xE8\xA0\xB5na ...' for column 'description' at row 1 in /home/boincadm/projects/nfs/html/inc/db_conn.inc:69

Another team with garbage characters?

davidpanderson commented 2 years ago

The XML file (boinc_teams.xml) is valid UTF-8, according to iconv: https://stackoverflow.com/questions/115210/how-to-check-whether-a-file-is-valid-utf-8 (although it probably contains lots of wrong characters because of earlier encoding issues.

So the problem is probably that your DB uses the latin1 encoding, and can't store certain UTF-8 characters. Perhaps the 8.1 version of mysqli is the first version that checks this.

If this is the case, the likely solution is to convert the database (at least the fields that hold user-supplied data) to utf8mb4. I tried doing this on a test project and immediately ran into problems. I don't have time to follow through on this. It's not super important since BOINC-wide teams don't change much.

gchilders commented 2 years ago

First, I had to use

SET SQL_MODE='ALLOW_INVALID_DATES';

since mysql doesn't like dates to be 0. After that I did

alter table team modify column name varchar(254) character set utf8 collate utf8_unicode_520_ci, modify column description text character set utf8 collate utf8_unicode_520_ci;

I couldn't use utf8mb4 because that resulted in a key length of over 1000 bytes, which isn't allowed apparently. After that I got a little further, but still got stuck on

Processing SETI.KHERSON redacted@email case 1 updating PHP Fatal error: Uncaught mysqli_sql_exception: Incorrect string value: '\xF0\xB1\xAE\xAD\xF1\xAA...' for column 'description' at row 1 in /home/boincadm/projects/nfs/html/inc/db_conn.inc:69

davidpanderson commented 2 years ago

Seems to me the long-term solution is to change all fields with user-supplied text (some fields of the user and team tables, forum stuff, maybe others) to utf8mb4. This may require shortening some of these fields (to 250 chars?) because of the 1000 byte key limit.