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

Admin field not syncronized #22

Open
guppy42 opened this issue Jan 23, 2024 · 0 comments
Open

Admin field not syncronized #22

guppy42 opened this issue Jan 23, 2024 · 0 comments
Assignees

Comments

@guppy42
Copy link

guppy42 commented Jan 23, 2024

Short description

The admin field is completely ignored by clients and while logins work all the user have access to is the logout button.
Not sure why this issue hasn't cropped up before I suspect it may be down to mysql version or driver.

Setup:

Server:

TYPO3 Version		12.4.10
Webserver		Apache
PHP Version		8.2.15
Database (Default)	MySQL 8.0.35-27 / pdo_mysql
Application Context	Production
Operating System	Linux 5.14.0-362.13.1.el9_3.x86_64
T3AM			5.0.0 (default.isServer=1)

Client:

TYPO3 Version		12.4.10
Webserver		Apache
PHP Version		8.2.15
Database (Default)	MySQL 8.0.35-27 / pdo_mysql
Application Context	Production
Operating System	Linux 5.14.0-362.13.1.el9_3.x86_64
Bootstrap Package	14.0.7
T3AM			5.0.0 

Problem location

In the function:
typo3conf/ext/t3am/Classes/Domain/Factory/UserFactory.php :: toDatabaseConformArray

The database columns are compared to the JSON keys of the user object.

This works for every field except admin due to it's array key being stored escaped:

var_dump($columns):

array(31) {
 ....
["avatar"]=>
  object(Doctrine\DBAL\Schema\Column)#1356 (16) {
  ....
 }
["password"]=>
  object(Doctrine\DBAL\Schema\Column)#1355 (16) {
...
 }
  ["`admin`"]=>
  object(Doctrine\DBAL\Schema\Column)#1367 (16) {
    ["_name":protected]=>
    string(5) "admin"
    ["_namespace":protected]=>
    NULL
    ["_quoted":protected]=>
    bool(false)
    ["_type":protected]=>
    object(Doctrine\DBAL\Types\SmallIntType)#1282 (0) {
    }
    ["_length":protected]=>
    NULL
    ["_precision":protected]=>
    int(10)
    ["_scale":protected]=>
    int(0)
    ["_unsigned":protected]=>
    bool(true)
    ["_fixed":protected]=>
    bool(false)
    ["_notnull":protected]=>
    bool(true)
    ["_default":protected]=>
    string(1) "0"
    ["_autoincrement":protected]=>
    bool(false)
    ["_platformOptions":protected]=>
    array(0) {
    }
    ["_columnDefinition":protected]=>
    NULL
    ["_comment":protected]=>
    NULL
    ["_customSchemaOptions":protected]=>
    array(0) {
    }
  }
  ["usergroup"]=>
  object(Doctrine\DBAL\Schema\Column)#1363 (16) {
    ....
  }

( the "..." above is just me cropping out irelevant info. )

The problem is that the json object contains the key "admin" where as $columns only contains "`admin`" ( mysql escape )

The quick & dirty solutions would be to loop over the $columns array like so:

        foreach ( $columns as $key=>$val ){
          $columns[trim($key,'`')]=$val;
       }
      

Which would effectively create a duplicate for escaped keys - not a pretty solution by any means, but it works (tested).

Any better way to fix it?

@dhoffmann1979 dhoffmann1979 self-assigned this Jan 25, 2024
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

No branches or pull requests

2 participants