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

fix(knowbase): Usage of $link parameter is deprecated #18747

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Jan 17, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

Prevent error message:

glpiphplog.INFO:   *** PHP User deprecated function (16384): Usage of `$link` parameter is deprecated. See `DbUtils::getUserName()`. in .../src/Toolbox.php at line 411
  Backtrace :
  src/Toolbox.php:411                                trigger_error()
  src/autoload/dbutils-aliases.php:477               Toolbox::deprecated()
  :                                                  getUserName()
  .../Application/View/Extension/PhpExtension.php:91 call_user_func_array()
  ...tes/c7/c72b5b27661bd718f1e6bba6e8d1e266.php:135 Glpi\Application\View\Extension\PhpExtension->call()
  vendor/twig/twig/src/Template.php:431              __TwigTemplate_3ff457c41796e09aa1e3b83ed2b25246->block_form_fields()
  ...tes/c0/c09802a815195ad87a29b227a97dc252.php:119 Twig\Template->yieldBlock()
  vendor/twig/twig/src/Template.php:387              __TwigTemplate_8907afca8f67fdf5154c467403b4faba->doDisplay()
  ...ates/c7/c72b5b27661bd718f1e6bba6e8d1e266.php:52 Twig\Template->yield()
  vendor/twig/twig/src/Template.php:387              __TwigTemplate_3ff457c41796e09aa1e3b83ed2b25246->doDisplay()
  vendor/twig/twig/src/Template.php:343              Twig\Template->yield()
  vendor/twig/twig/src/TemplateWrapper.php:58        Twig\Template->display()
  src/Glpi/Application/View/TemplateRenderer.php:183 Twig\TemplateWrapper->display()
  src/KnowbaseItem.php:844                           Glpi\Application\View\TemplateRenderer->display()
  src/KnowbaseItem.php:271                           KnowbaseItem->showForm()
  src/CommonGLPI.php:681                             KnowbaseItem::displayTabContentForItem()
  ajax/common.tabs.php:112                           CommonGLPI::displayStandardTab()
  ...Glpi/Controller/LegacyFileLoadController.php:59 require()
  vendor/symfony/http-kernel/HttpKernel.php:101      Glpi\Controller\LegacyFileLoadController->Glpi\Controller\{closure}()
  ...ymfony/http-foundation/StreamedResponse.php:106 Symfony\Component\HttpKernel\HttpKernel::Symfony\Component\HttpKernel\{closure}()
  vendor/symfony/http-foundation/Response.php:423    Symfony\Component\HttpFoundation\StreamedResponse->sendContent()
  src/Glpi/Kernel/Kernel.php:235                     Symfony\Component\HttpFoundation\Response->send()
  public/index.php:58                                Glpi\Kernel\Kernel->sendResponse()
  
glpiphplog.INFO:   *** PHP User deprecated function (16384): Usage of `$link` parameter is deprecated. Use `getUserLink()` instead. in .../src/Toolbox.php at line 411
  Backtrace :
  src/Toolbox.php:411                                trigger_error()
  src/DbUtils.php:1781                               Toolbox::deprecated()
  src/autoload/dbutils-aliases.php:480               DbUtils->getUserName()
  :                                                  getUserName()
  .../Application/View/Extension/PhpExtension.php:91 call_user_func_array()
  ...tes/c7/c72b5b27661bd718f1e6bba6e8d1e266.php:135 Glpi\Application\View\Extension\PhpExtension->call()
  vendor/twig/twig/src/Template.php:431              __TwigTemplate_3ff457c41796e09aa1e3b83ed2b25246->block_form_fields()
  ...tes/c0/c09802a815195ad87a29b227a97dc252.php:119 Twig\Template->yieldBlock()
  vendor/twig/twig/src/Template.php:387              __TwigTemplate_8907afca8f67fdf5154c467403b4faba->doDisplay()
  ...ates/c7/c72b5b27661bd718f1e6bba6e8d1e266.php:52 Twig\Template->yield()
  vendor/twig/twig/src/Template.php:387              __TwigTemplate_3ff457c41796e09aa1e3b83ed2b25246->doDisplay()
  vendor/twig/twig/src/Template.php:343              Twig\Template->yield()
  vendor/twig/twig/src/TemplateWrapper.php:58        Twig\Template->display()
  src/Glpi/Application/View/TemplateRenderer.php:183 Twig\TemplateWrapper->display()
  src/KnowbaseItem.php:844                           Glpi\Application\View\TemplateRenderer->display()
  src/KnowbaseItem.php:271                           KnowbaseItem->showForm()
  src/CommonGLPI.php:681                             KnowbaseItem::displayTabContentForItem()
  ajax/common.tabs.php:112                           CommonGLPI::displayStandardTab()
  ...Glpi/Controller/LegacyFileLoadController.php:59 require()
  vendor/symfony/http-kernel/HttpKernel.php:101      Glpi\Controller\LegacyFileLoadController->Glpi\Controller\{closure}()
  ...ymfony/http-foundation/StreamedResponse.php:106 Symfony\Component\HttpKernel\HttpKernel::Symfony\Component\HttpKernel\{closure}()
  vendor/symfony/http-foundation/Response.php:423    Symfony\Component\HttpFoundation\StreamedResponse->sendContent()
  src/Glpi/Kernel/Kernel.php:235                     Symfony\Component\HttpFoundation\Response->send()
  public/index.php:58                                Glpi\Kernel\Kernel->sendResponse()
  

Screenshots (if appropriate):

image

@Rom1-B Rom1-B changed the title fix(knowbase): Usage of parameter is deprecated fix(knowbase): Usage of $link parameter is deprecated Jan 17, 2025
@@ -62,7 +62,7 @@
{% endset %}
{% endif %}
{% if item.fields['users_id'] %}
{% set user_field = call('getUserName', [item.fields['users_id'], has_profile_right('user', constant('READ')) ? 1 : 0]) %}
{% set user_field = call('getUserLink', [item.fields['users_id']]) %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you can just drop the profile condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUserLink() already does the check:

image

@trasher trasher merged commit 2f33ab8 into glpi-project:main Jan 17, 2025
9 checks passed
@Rom1-B Rom1-B deleted the fix_getUserName branch January 17, 2025 10:10
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

Successfully merging this pull request may close these issues.

3 participants