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 uncaught error "Argument #1 ($id) must be of type int, null given" when userOwner of userModification is null #15914

Closed
wants to merge 1 commit into from

Conversation

atul-emico
Copy link

When userOwner and userModification are not set that time search by id is throwing error.

php.CRITICAL: Uncaught Error: Pimcore\Model\User\AbstractUser::getById(): Argument #1 ($id) must be of type int, null given, called in {project_root}/var/cache/acceptance/twig/ac/ac4a382cb38374880f7892b33abdbe63.php on line 174 {"exception":"[object] (TypeError(code: 0): Pimcore\Model\User\AbstractUser::getById(): Argument #1 ($id) must be of type int, null given, called in {project_root}/var/cache/acceptance/twig/ac/ac4a382cb38374880f7892b33abdbe63.php on line 174 at {project_root}/vendor/pimcore/pimcore/models/User/AbstractUser.php:41)"} []

File - templates/searchadmin/search/quicksearch/info_table.html.twig
Line number - 52 - 66

{% set owner = pimcore_user(element.getUserOwner()) %}
{% if owner is instanceof('\Pimcore\Model\User') %}

{{ 'owner'|trans([],'admin') }}
{{ owner.name }}

{% endif %}

  {% set editor = pimcore_user(element.getUserModification()) %}
  {% if editor is instanceof('\\Pimcore\\Model\\User') %}
      <tr>
          <th>{{ 'usermodification'|trans([],'admin') }}</th>
          <td>{{ editor.name }}</td>
      </tr>
  {% endif %}

There is no condition set.

…" when userOwner of userModification is null
@CLAassistant
Copy link

CLAassistant commented Sep 7, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Review Checklist

  • Target branch (11.0 for bug fixes, others 11.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@sonarcloud
Copy link

sonarcloud bot commented Sep 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@blankse
Copy link
Contributor

blankse commented Sep 7, 2023

I think, we should change the template:

{% set userModificationId = element.getUserModification() %}
{% set editor = userModificationId ? pimcore_user(userModificationId) : null %}

@blankse
Copy link
Contributor

blankse commented Sep 7, 2023

@atul-emico I created a alternative PR pimcore/admin-ui-classic-bundle#262

@kingjia90
Copy link
Contributor

Closing in favor of pimcore/admin-ui-classic-bundle#262

Thank you again for reporting and the PRs!

@kingjia90 kingjia90 closed this Sep 7, 2023
@atul-emico
Copy link
Author

@blankse

Thanks for the quick fix. That will be good approach.

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.

None yet

4 participants