Menu

#847 Control select not display the value in Adminer Editor

4.8.1
closed-fixed
nobody
None
8
2025-02-22
2022-09-19
No

I am using Adminer Editor 4.8.1. With PHP 8.0.10 (on Apache 2.4.) it works without errors. I have upgraded to PHP 8.1.10 and this problems appears:

Listing of table rows displays correctly value in column with foreign key into referenced table, but if one row is displayed (.../editor/?username=user&edit=article&where%5Bid%5D=1) the select control has no selected value.

I have tested also the Editor 4.7.9 on PHP 8.1.10 - the same error.

After downgrading back to PHP 8.0.10 Editor works correctly.

1 Attachments

Discussion

  • Miloš Brecher

    Miloš Brecher - 2022-09-19

    Iam using mySQL mysqlnd 8.1.10

     
  • Miloš Brecher

    Miloš Brecher - 2022-09-19

    Hi,

    I have succeeded to fix the error, the error was probably caused a difference type of database column integer selecting into PHP (PDO??). In function generating the SELECT html, file /adminer/include/function.inc.php, line 194 is function optionList getting in argument $selected the value of the int column in database table (foreign key). I have tested - PHP 8.0.10 it is number but type string, but in PHP 8.1.10 it is nubmer but type integer !!! And on line 203, where is creating the html attribute selected for <option> which represents the value is comparison type strict === and for $use_keys = true (for Editor) the $key is retyping to (string) but the value in $selected NOT !! So I have made a slight change of the code - adding retyping to (string) lselected.</option>

    The code is:
    
    foreach ($opts as $key => $val) {
            $return .= '<option' . ($use_keys || is_string($key) ? ' value="' . h($key) . '"' : '') . (($use_keys || is_string($key) ? (string) $key : $val) === (string) $selected ? ' selected' : '') . '>' . h($val);
        }
    

    And this works in PHP 8.1.10 !!

    I havent tested wheather it works also in PHP 8.0.10 but probably yes.

                I hope I have helped you to fix this bug in the official distribution of Editor.
    
     
  • Jakub Vrána

    Jakub Vrána - 2025-02-19

    If $key is an empty string and $selected is null then your code will match them which is wrong.

     
  • Miloš Brecher

    Miloš Brecher - 2025-02-21

    Hi Jakub, it's nice to hear from you.

    My fix is just emergency fix, because I urgently need use Editor on home development machine with Windows. I do not fully undersand the source code of Adminer/Editor. The root of the bug will be probably in library PDO in version >= PHP 8.1 for Windows, I didnt found the root of the bug. My fix isnt correct solution of the problem, I know.

    What you can do is compare Adminer/Editor on PHP 8.1 on Linux and Windows and found the place in the PDO where is difference and fix the PDO bug directly there

     
  • Jakub Vrána

    Jakub Vrána - 2025-02-22
    • status: open --> closed-fixed
     
  • Jakub Vrána

    Jakub Vrána - 2025-02-22

    I've merged your change. Hopefully it wouldn't break anything else.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.