Problem/Motivation

Line 189 of ContentTranslationController.php has a test which cannot possibly have any other value than FALSE. It serves no purpose but to confuse the reader of the code.

Steps to reproduce

Extract the statements establishing the values of $operations and $links and try to access $links->links.

$operations = ['data' => ['#type' => 'operations', '#links' => []]];
$links = &$operations['data']['#links'];
$foo = $links->links;

It is clear that isset($links->links[$langcode]['url']) will always return FALSE, for any value of $langcode.

Proposed resolution

Remove the dead code, assigning $link = ['url' => $entity->toUrl()].

Remaining tasks

Make the proposed change.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/A.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bkline created an issue. See original summary.

larowlan’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative
larowlan’s picture

Issue tags: +Novice
andregp’s picture

I'll work on it and send a patch in a moment :)

andregp’s picture

Status: Active » Needs review
FileSize
1.03 KB

Here is the patch with the proposed solution.

Libbna’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
92.5 KB

Reviewed #5 patch and it LGTM.

alexpott’s picture

Version: 9.3.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

@Libbna thank you for looking into this issue.

Posting screenshots of your codebase or command-line interface does not advance the issue, since the automated testing infrastructure tells us whether the change set still applies correctly.

So, I've removed the issue credit for that screenshot. In the future, you can get credit for issues by reading the issue to understand its purpose, and posting your review or testing of that purpose. Thank you!

I've credited @bkline@rksystems.com for finding this issue as it is a nice catch. This code went into core is this state back in #1188388: Entity translation UI in core.

Committed and pushed 8bd8fa25c8 to 10.0.x and 70c11f898e to 9.5.x and a629a3068a to 9.4.x. Thanks!

  • alexpott committed 8bd8fa2 on 10.0.x
    Issue #3278032 by andregp, bkline@rksystems.com: Remove dead code from...

  • alexpott committed 70c11f8 on 9.5.x
    Issue #3278032 by andregp, bkline@rksystems.com: Remove dead code from...

  • alexpott committed a629a30 on 9.4.x
    Issue #3278032 by andregp, bkline@rksystems.com: Remove dead code from...
bkline’s picture

Libbna’s picture

@alexpott Thank you for the information. I will make sure to review it properly next time.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.