Problem/Motivation

Some of functions in boostrap are missing the data type for the return. We should fix this. There also is some dead code which makes the core a little bit more complex to understand, so we should remove that as well.

Proposed resolution

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug since we don't maintain our own code standards (for documentation)
Issue priority Normal
Unfrozen changes Unfrozen because it only changes documentation
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

googletorp created an issue. See original summary.

googletorp’s picture

Status: Active » Needs review
FileSize
1.72 KB

While cleaning up the documentation, my editor showed that we have a variable defined in drupal_get_filename() which isn't used, so I opted to delete this (for documentation purpose, to make the function easier to understand).

I don't know if we want to split that out, but seems like a lot to create an issue just to remove

$original_type = $type;
googletorp’s picture

Also I added an issue for the @todo, so we can keep track of it.

jhodgdon’s picture

Title: Add missing @return type decomentation and remove dead code in bootrap » Add missing @return type decomentation and remove dead code in bootsrap
Status: Needs review » Needs work

Agreed, $original_type is only declared in that one line and then never mentioned in any other line of bootstrap.inc. And most of your changes here look good, thanks!

A few minor things to fix:

  1. +++ b/core/includes/bootstrap.inc
    @@ -341,7 +341,7 @@ function format_string($string, array $args) {
    + * @return boolean
    

    boolean => bool
    [when used as a type]

  2. +++ b/core/includes/bootstrap.inc
    @@ -945,7 +945,7 @@ function drupal_placeholder($text) {
    + * @return array
    

    Normally instead of @return array, we'd prefer to have something like:

    @return string[]
    @return \Some\Class\Name[]
    etc.

    So if you know what type is in the array, that would be preferable.

cilefen’s picture

Title: Add missing @return type decomentation and remove dead code in bootsrap » Add missing @return type decomentation and remove dead code in bootstrap
jhodgdon’s picture

Title: Add missing @return type decomentation and remove dead code in bootstrap » Add missing @return type documentation and remove dead code in bootstrap

Let's get the title actually spelled correctly. Third time's a charm. ;)

googletorp’s picture

Status: Needs work » Needs review
FileSize
1.72 KB
435 bytes

4.1 Changed boolean to bool (fun fact we have around 100 @return boolean and 1500 @return bool)

4.2 The function is returning an array of arrays, so that's why I opted for @return array

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Fair enough. Looks good!

xjm’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/includes/bootstrap.inc
@@ -191,8 +191,8 @@ function drupal_get_filename($type, $name, $filename = NULL) {
-  // @todo Remove false-exposure of profiles as modules.
-  $original_type = $type;
+  // @todo Remove false-exposure of profiles as modules:
+  //   https://www.drupal.org/node/2579097

Technically this shouldn't really be included in the scope of the issue. I confirmed that the $original_type parameter is not really used in any case.

I think we also should not add the link to the @todo here because I think there must be an existing issue for this other than #2579097: Remove false-exposure of profiles as modules (about the way that profiles are treated as modules). Maybe we could repurpose that other issue to be about tracking down the correct issue and adding it to the @todo. :) Commented over there.

snehi’s picture

Status: Needs work » Needs review
FileSize
1.62 KB
957 bytes

Done as suggested in #9.

googletorp’s picture

Status: Needs review » Reviewed & tested by the community

@xjm makes sense, I'll do some investigation and post find findings unless some ones beats me to it.

Since the actually doc changes already has been approved and we are handling the comments on #9 I'm putting this back to RTBC.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Well, let's not actually remove the @todo please, it's still valid.

Nitesh Pawar’s picture

FileSize
612 bytes

Interdiff of #10

Nitesh Pawar’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

This patch is still at Needs Work due to #12.

snehi’s picture

Issue tags: +Needs reroll
jhodgdon’s picture

Issue tags: -Needs reroll

This is not a reroll. It needs a fix to the patch. See #12.

Nitesh Pawar’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

New patch on latest revision.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks, but this patch has problems that are not in the most recent patch. Please start with that patch and just leave the lines with the @todo in it.

ashhishhh’s picture

Status: Needs work » Needs review
FileSize
1.44 KB
431 bytes

Patch given on #10 no more work.
In #18, I made only one change

@@ -859,7 +859,7 @@
  *   internally and should not be passed in; use drupal_static_reset() instead.
  *   (This function's return value should not be used when TRUE is passed in.)
  *
- * @return $data
+ * @return array
  *   Returns a variable by reference.
jhodgdon’s picture

Status: Needs review » Needs work
+++ b/core/includes/bootstrap.inc
@@ -859,7 +859,7 @@ function drupal_classloader_register($name, $path) {
- * @return
+ * @return array

This is the return value of drupal_static_reset(). It is not an array. So I do not understand why you made this change? It is incorrect. Please put it back the way it was.

It would really help if people working on issues would follow the instructions given by reviewers, especially Drupal Core branch/documentation maintainers. Thanks!

ashhishhh’s picture

Status: Needs work » Needs review
FileSize
1.44 KB
431 bytes
jhodgdon’s picture

Status: Needs review » Needs work

ONCE AGAIN, we need to return to the patch in #12, which was the closest patch that we had, and make sure EVERYTHING in there gets into the new patch, EXCEPT that we do not want to remove the @todo that was there. FOR SOME REASON no one has listened to this instruction. PLEASE do not ignore this again. The patches since then all have problems that I don't care to review. Thanks!

ashhishhh’s picture

@jhodgdon, There is no patch available @ #12.
Can you check once more & specify, which one is close to final one.

jhodgdon’s picture

Sorry, see comment #12 for instructions. The most recent nearly OK patch is just before that in comment #10.

Nitesh Pawar’s picture

Status: Needs work » Needs review
FileSize
1.71 KB

hi jhodgdon,

I created patch on latest revision and removed @todo.

googletorp’s picture

Status: Needs review » Needs work

Getting closer, not quite there yet.

+++ b/core/includes/bootstrap.inc
@@ -859,7 +858,7 @@ function drupal_classloader_register($name, $path) {
+ * @return $data

It should be the data type, not the variable name after @return

naveenvalecha’s picture

Status: Needs work » Needs review
FileSize
1.71 KB
517 bytes

Edit : Addressed #27

jhodgdon’s picture

  1. +++ b/core/includes/bootstrap.inc
    @@ -199,7 +199,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
    -  // @todo Remove false-exposure of profiles as modules.
    

    AGAIN: we do NOT want to remove the @todo in this patch. Please leave the @todo as it is in the code. Sorry for shouting but can you PLEASE read the instructions!

  2. +++ b/core/includes/bootstrap.inc
    @@ -859,7 +858,7 @@ function drupal_classloader_register($name, $path) {
    + * @return array
      *   Returns a variable by reference.
    

    I am pretty sure I have said this in a previous review too [yes, see #21], but I will try again.

    This function's return value is NOT necessarily an array. If anything it is "mixed", but that is also misleading because it is returning a variable by reference, not some data. So I think we should not put a type here at all.

  3. ONCE AGAIN... Can you PLEASE PLEASE PLEASE PLEASE take a look at the patch in #10? There is quite a bit in there that is NOT in the latest patch, and there are mistakes in the latest patches that are not in #10. I have asked repeatedly... WHY are you ignoring me? Either start over with #10, doing what was asked in #12 and several times since then, or explain why you are not able to follow this very simple request. I don't get it. If this happens again I will simply close this issue as "won't fix". It is a waste of my time to continue with this kind of behavior.
Nitesh Pawar’s picture

jhodgdon’s picture

Status: Needs review » Closed (won't fix)

Sorry. This issue is going nowhere, my instructions are always ignored, and each patch has more problems than the last.

And to top it off, we have new guidelines on issue scope which this issue doesn't comply with. So I'm just going to mark it as Won't Fix.

If you'd like to fix @return types, I think there may be a meta-issue about it, which you can search for. Meanwhile, see
https://www.drupal.org/core/scope
for the scope guidelines. Sorry, but this is a Won't Fix as it is.