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

Clone Profile issue on version .17 #122

Open
dhrzic opened this issue Nov 10, 2024 · 6 comments
Open

Clone Profile issue on version .17 #122

dhrzic opened this issue Nov 10, 2024 · 6 comments

Comments

@dhrzic
Copy link

dhrzic commented Nov 10, 2024

Hello,

an issue appears when a profile is cloned on version .17.

Here is the output log:
[2024-11-10 11:31:00] glpiphplog.CRITICAL: *** Uncaught Exception TypeError: Glpi\Toolbox\ArrayNormalizer::normalizeValues(): Argument #1 ($array) must be of type array, string given, called in /var/www/html/glpi/src/Profile.php on line 520 in /var/www/html/glpi/src/Toolbox/ArrayNormalizer.php at line 40
Backtrace :
src/Profile.php:520 Glpi\Toolbox\ArrayNormalizer::normalizeValues()
src/CommonDBTM.php:1305 Profile->prepareInputForAdd()
marketplace/behaviors/inc/common.class.php:213 CommonDBTM->add()
marketplace/behaviors/front/common.form.php:38 PluginBehaviorsCommon::cloneItem()
public/index.php:82 require()

Best Regards,
Domagoj

@ftoledo
Copy link

ftoledo commented Dec 12, 2024

same here!

@ValFran99
Copy link

hello, it seems that the problem is in this code block

src/Profile.php, line 520

 if (isset($input["managed_domainrecordtypes"])) {
                $input["managed_domainrecordtypes"] = exportArrayToDB(
                ArrayNormalizer::normalizeValues($input["managed_domainrecordtypes"], 'intval')
                );
         }

when trying to clone a profile, the field "managed_domainrecordtypes" is "NULL" instead of NULL and that isset() mistakenly returns true.

As a hotfix, commenting out the code block

// Manage NULL fields in original
      foreach($input as $k => $v) {
         if (is_null($input[$k])) {
            $input[$k] = "NULL";
         }
      }

in marketplace/behaviors/inc/common.class.php, line 181 seems to fix this problem for now.

@possebon
Copy link

I'm having the same issue. I tried to do the fix but in my case did not work (or I did something wrong).

I edited the marketplace/behaviors/inc/common.class.php, line 181

In my case my original code was:

// Manage NULL fields in original 
foreach($input as $k => $v) {
if (is null(Sinput [$k])) {
$input [$k] = "NULL" :
}

}

I change to

// Manage NULL fields in original 
#foreach($input as $k => $v) {
#if (is null(Sinput [$k])) {
#$input [$k] = "NULL" :
#}

#}

If someone else has another tip, will be great

@ftoledo
Copy link

ftoledo commented Jan 15, 2025

use // for comments on every line
or all the block:

/*
foreach($input as $k => $v) {
if (is null(Sinput [$k])) {
$input [$k] = "NULL" :
}

}
*/

@SilvaFernando
Copy link

Worked for me, it's possible merge this solution in next release?

@SilvaFernando
Copy link

10.0.18 same problem.

Image

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

5 participants