php / php/php-src

metadata checks (charsetnr) in various mysqli tests fail

Aperta
#21,338 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Extension: mysqli Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.2k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

The following test:

sapi/cli/php -f run-tests.php ext/mysqli/tests/mysqli_fetch_field.phpt

Resulted in this output:

========DIFF========
--
       ["decimals"]=>
       int(0)
     }
057+ [004] Expecting charset utf8/33 got 192
     bool(false)
     mysqli_result object is already closed
     array(1) {
--
========DONE========
FAIL mysqli_fetch_field() [ext/mysqli/tests/mysqli_fetch_field.phpt] 
=====================================================================
Number of tests :     1                 1
Tests skipped   :     0 (  0.0%) --------
Tests warned    :     0 (  0.0%) (  0.0%)
Tests failed    :     1 (100.0%) (100.0%)
Tests passed    :     0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      : 0.110 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
mysqli_fetch_field() [ext/mysqli/tests/mysqli_fetch_field.phpt]
=====================================================================

mysqli_set_charset() selects a character set by name only.
However, in MySQL/MariaDB a character set can have multiple collations, and the actual collation used determines the internal character set number (charsetnr) returned in metadata.

Several tests in the ext/mysqli test suite assume that setting utf8mb3 results in charsetnr = 33 (which corresponds to utf8mb3_general_ci). This assumption is not valid when the server default collation differs.

As a result, multiple tests fail depending on server configuration.

Possible workarounds (quick fix):

  • use %d in the expect section
  • use SET NAMES utf8mb3 COLLATE 'utf8mb3_general_ci' if you want to explicitly test for this character set/collation.
PHP Version
PHP 8.3.6 (cli) (built: Jan  7 2026 08:40:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
Operating System

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da ext/mysqli/tests/mysqli_fetch_field.phpt ed esegui il comando sapi/cli/php mostrato su un server con una collation predefinita diversa. Cerca nei test ext/mysqli correlati le aspettative codificate per charsetnr 33, quindi verifica che i test interessati abbiano esito positivo, accettando il valore dipendente dal server oppure selezionando esplicitamente la collation prevista.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
mariadb, mysql, php
Ambito
databases, testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.