Problem/Motivation

I've read this 4 times and I don't get it:

   * @param $graph
   *   A three dimensional associated array, with the first keys being the names
   *   of the vertices, these can be strings or numbers. The second key is
   *   'edges' and the third one are again vertices, each such key representing
   *   an edge. Values of array elements are copied over.
   *
   *   Example:
   *   @code
   *     $graph[1]['edges'][2] = 1;
   *     $graph[2]['edges'][3] = 1;
   *     $graph[2]['edges'][4] = 1;
   *     $graph[3]['edges'][4] = 1;
   *   @endcode
   *
   *   On return you will also have:
   *   @code
   *     $graph[1]['paths'][2] = 1;
   *     $graph[1]['paths'][3] = 1;
   *     $graph[2]['reverse_paths'][1] = 1;
   *     $graph[3]['reverse_paths'][1] = 1;
   *   @endcode
* A three dimensional associated array, with the first keys being the names
* of the vertices, these can be strings or numbers.

This sentence isn't grammatical.

The second key is
* 'edges' and the third one are again vertices

I wasn't sure if this was a typo and it should be quoted as 'vertices', a literal string. But looking at the example, it's not.

each such key representing
* an edge.

Does that mean that each key of the 'edges' array is the name of a vertex, that is, matches a key in the main array?

> Values of array elements are copied over

I have no idea what that means.

Copied over -- does that mean copied from one place to another? In which case, from where to where? Or does it mean overwritten?

Is it trying to say that the values don't mean anything? They are all 1 in the example code, so I suspect that might be the case.

> * On return you will also have:

Return? This is a constructor. It doesn't return anything. What does this mean?

Remaining tasks

  • Convert the latest patch to a merge request.
  • Update the docblock as per #16.

Issue fork drupal-3200162

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Issue tags: +Novice, +Bug Smash Initiative

This might be something a novice can progress

There's some uses of this in core for sorting module dependencies and also in default content module for sorting imports

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ultimike’s picture

Category: Bug report » Task
Priority: Major » Normal
Issue summary: View changes
Issue tags: +Prague2022

Please hold this issue for first time contributors at DrupalCon Prague 2022.

chaubeyji’s picture

StatusFileSize
new2.21 KB

Please check if this is correct.

chaubeyji’s picture

please ignore patch on comment #7.

chaubeyji’s picture

StatusFileSize
new969 bytes

Please see this one.

chaubeyji’s picture

Status: Active » Needs review
kimberleycgm’s picture

Issue summary: View changes
kimberleycgm’s picture

Hi chaubeyji, whilst everyone appreciates contributions and moving these issues forwards, in comment #6 ultimike had requested that this issue be held for Prague 2022 DrupalCon first time contributors.

I would encourage the reading of the issue comment thread prior to updating to make sure this is avoided as a lot of time is put into doing issue triage to identify these for the events.

The review of the patch can still be worked on by the first time contributors.

chaubeyji’s picture

Thank you @kimberleycgm, I am a first time contributor, thank you for comment, I will keep it in mind.

kimberleycgm’s picture

Thank you!

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ksenzee’s picture

Status: Needs review » Needs work

I think the docblock still needs more of a rewrite.

> Return? This is a constructor. It doesn't return anything. What does this mean?

My guess is that at some point this object was refactored, and the documentation didn't get a matching refactor. The constructor says it instantiates the "depth first search" object. It probably used to contain the code that's now in ::searchAndSort(), and when that got moved to its own method, the docblock didn't move along with it. So the constructor docblock should instead start out with "Instantiates the directed acyclic graph object."

For the description under @param $graph, I'd say something more like

A three-dimensional associative array, keyed by the names of the graph's vertices, which can be strings or numbers. Each vertex may have an 'edges' key, whose value is an array keyed by the names of the vertices connected to it; the values in this array can be simply TRUE or may contain other data.

The example in the code block is good—vital even—but I think it should be preceded by a little diagram of the graph, like the one in the comments at \Drupal\Tests\Component\Graph\GraphTest::testDepthFirstSearch(). For the example given, the diagram would be

1 --> 2 --> 3
      |     |
      |     v
      + --> 4

or if we can use ASCII Extended in docblocks,

1────►2────►3
      │     │
      │     ▼
      └───► 4

The second @code block in the constructor—the one with 'paths' and 'reverse_paths' keys—should be moved to the ::searchAndSort() method, because it's describing the return value of ::searchandSort() if you pass it the graph described above.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cecelias’s picture

Issue tags: +Portland2024
Novice issue reserved for the Mentored Contribution during the Contribution Day at DrupalCon Portland 2024. After the 8th of May 2024, this issue returns to being open to all. Thanks
xjm’s picture

Issue summary: View changes

Updating the remaining tasks section.

NexusNovaz made their first commit to this issue’s fork.

nexusnovaz’s picture

Status: Needs work » Needs review

Hi, I've made MR 8124 which is ready for review. I've added both the patch from #9 and the changes in #16.

Thanks

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.23 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nexusnovaz’s picture

Status: Needs work » Needs review
ksenzee’s picture

Status: Needs review » Needs work

Thanks for working on this! It looks like the diagram needs an update—the code and the diagram don't currently match. I think lines 28-30 need to be indented, so that 2 and 3 lead to 4, not 1 and 2 leading to 4.

nexusnovaz’s picture

Status: Needs work » Needs review

Nice spot @ksenzee!

Made that adjustment to the MR and should be ready for review!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Failure is unrelated.

Appears feedback has been addressed.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

@NexusNovaz, thank you for working on this issue! And for you prompt replies to feedback.

I have reviewed the MR and don't think that the example should be split into two parts, one in the constructor and one in the method searchAndSort. Instead, let's use the example of migrate process plugins where the examples are in the Class doc bloc. See MigrationLookup for one example.

brandonlira made their first commit to this issue’s fork.

brandonlira’s picture

Status: Needs work » Needs review

Hi @quietone

The previous MR (!8124) was quite outdated and significantly behind the 11.x branch. I initially attempted a rebase, but due to a large number of conflicts, it became difficult to manage cleanly.

To ensure a clean and conflict-free update, I’ve created a new branch and opened this fresh MR (!11606) with the necessary changes, fully rebased with the latest from 11.x.

All tests are now passing. Let me know if anything else is needed!

Thanks!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback to move example to class block seems to been addressed.

  • quietone committed bfe01e47 on 11.1.x
    Issue #3200162 by brandonlira, ksenzee, ultimike, larowlan, cecelias,...

  • quietone committed 6d25f705 on 11.x
    Issue #3200162 by brandonlira, ksenzee, ultimike, larowlan, cecelias,...
quietone’s picture

Version: 11.x-dev » 11.1.x-dev
Status: Reviewed & tested by the community » Fixed

@brandonlira, yes, thanks for the explanation. Have you seen rebase a merge request?

Thanks everyone for improving the documentation.!

Status: Fixed » Closed (fixed)

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

xjm’s picture

Restoring attribution.