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

When importing packages, hash types are not properly processed #4695

Merged
merged 2 commits into from
Apr 11, 2022

Conversation

ddb4github
Copy link
Contributor

  • $ignorable_type_code_hashes is not initialized before used
  • Incorrect arg position of array_search

@netniV netniV merged commit e20a713 into Cacti:1.2.x Apr 11, 2022
@ddb4github ddb4github deleted the fiximport branch April 11, 2022 12:40
@TheWitness
Copy link
Member

This fix does not fix the package corruption. Should get it fixed later today.

TheWitness added a commit that referenced this pull request Apr 12, 2022
The packages included in this commit should fix all the issues encountered from the release.
It also reverted #4695 that reserved the order of array_search() by accident.
@ddb4github
Copy link
Contributor Author

This fix does not fix the package corruption. Should get it fixed later today.

This PR only fix syntax error if $dep_status != 'met'
For array_search func, the 2nd param must be array, current is NULL

        var_dump($dep_hash);
        var_dump($dep_status);
        var_dump($ignorable_type_code_hashes);
        if ($dep_status == 'met') {
            $dep_status_text = "<span class='foundDependency'>" . __('Found Dependency:') . '</span>';
        } else if (array_search($ignorable_type_code_hashes, $dep_hash) === false) {
            $dep_status_text = "<span class='unmetDependency'>" . __('Unmet Dependency:') . '</span>';
            $dep_errors = true;
        }
string(43) "hash_0101037fc923d81fd11083628731e271c3fa6a"
string(3) "met"
NULL

@TheWitness
Copy link
Member

TheWitness commented Apr 12, 2022

The $needle is what we are searching for (aka $dep_hash). The $ingorable_type_code_hashes are the $haystack.

array_search($needle, $haystack);

@netniV
Copy link
Member

netniV commented Apr 13, 2022

@TheWitness is correct @ddb4github. The function should have the needle first: https://www.php.net/manual/en/function.array-search.php

@netniV
Copy link
Member

netniV commented Apr 13, 2022

However, I have just re-committed the correct array_search call as it was wrong in the code still. There is also the removal of a check that the ignorable's variable exists. That check created an empty array which may not be desirable either so I've flagged that on the commit and @TheWitness and I will likely have to discuss how that could happen if at all.

@ddb4github
Copy link
Contributor Author

@TheWitness is correct @ddb4github. The function should have the needle first: https://www.php.net/manual/en/function.array-search.php

Yes, #4695 (comment) just show previous code line before you re-commit.

BTW, as your said (#4695 (comment)), $ingorable_type_code_hashes might be empty when the first array_search

@netniV netniV changed the title Fixed: wrong usages about $ignorable_type_code_hashes during import package When importing packages, hash types are not properly processed May 15, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants