Problem/Motivation
On #2676182: In the documentation, change all instances of "url" to "URL"., we are fixing the word "url" in documentation to its correct spelling, "URL".
This issue is something slightly different: the problem is that there are quite a few spots in the documentation that are mentioning the url() function [note the parens after url!], which does not exist any more in Drupal 8.
Note that there is still a Twig url() function, and a CSS url() function, and a JavaScript url() function, and several classes that have url() methods. However, there is no more bare PHP url() function in Drupal 8, so places in the docs that mention this function need to be replaced with something else.
Here's a grep command that checks for these, eliminating at least some of the false positives:
grep -R "url()" * | grep -v "::url()" | grep -v "_url()" | grep -v ">url()"
Proposed resolution
The question is what to replace the url() mentions with. For that, you'd probably need to look at the code and see what it's calling instead of url(). For instance, in system.module you find this:
* @param array $options
* Optional array of options to pass to url().
* @return \Drupal\Core\Url
* The full URL to authorize.php, using HTTPS if available.
*
* @see system_authorized_init()
*/
function system_authorized_get_url(array $options = array()) {
// core/authorize.php is an unrouted URL, so using the base: scheme is
// the correct usage for this case.
$url = Url::fromUri('base:core/authorize.php');
$url_options = $url->getOptions();
$url->setOptions($options + $url_options);
return $url;
}
The second line of docs is what mentions the url() function in error.
So, looking at the code, you can see that the options are actually added to the Url object by calling $url->setOptions(), and therefore a good way to change the documentation line (the second line above) would be something like this:
Optional array of options to set on the \Drupal\Core\Url object.
Similar fixes should be found for the other approximately 10 or 20 places in the docs that need fixing. Just be careful not to fix references to CSS or Twig functions, or class methods named url().
Remaining tasks
Make a patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff-18-21.txt | 2.46 KB | imalabya |
#21 | 2679953-21.patch | 6.19 KB | imalabya |
#18 | replace_mentions_of-2679953-18.patch | 6.19 KB | subharanjan |
#18 | interdiff-2679953-13-18.txt | 2.51 KB | subharanjan |
#16 | replace_mentions_of-2679953-16.patch | 6.23 KB | subharanjan |
Comments
Comment #2
aditya_anurag CreditAttribution: aditya_anurag as a volunteer and at Valuebound commentedComment #3
aditya_anurag CreditAttribution: aditya_anurag as a volunteer and at Valuebound commentedComment #4
jhodgdonThis patch seems to be fixing the word "url" to be "URL". That is the wrong patch for this issue. Please read the issue summary more carefullly.
Comment #5
jhodgdonActually deleting this file because it's just not related to this issue at all.
Next person to make a patch, please do not make an interdiff to the previous patch, as it is not relevant to this issue at all.
Comment #6
jhodgdonHopefully clarifying the issue summary.
Comment #7
AjitSHere is the result for the command
against branch 8.0.x
Attaching initial version of the patch, making changes about which I was confident. I made changes in the files:
I did not change any functions in the JS files or twig templates as mentioned in the issue summary.
I was particularly not sure about
core/lib/Drupal/Core/Asset/CssOptimizer.php
. The codeseems to make use of the
css()
function. So, I thought it would be wrong to make changes in the comments unless done in the code first. Please review :)Comment #8
jhodgdonI think that the stuff in the CSS classes is referring to the ability to use url(...) in CSS to indicate a background image URL and things like that, so I do not think it needs to be updated.
Anyway, this patch looks pretty good, thanks! A few things to fix:
This is first-line documentation for a function.
So it needs to be 1 line ending in . and followed by a blank line, not two lines.
Also... I don't think that the docs are really right... I am not sure this is used "with the Url object".
How about just taking out the whole "for use with url()" part entirely?
Let's make this just say "... options to set on the URL, such as..."
The thing is, the l() function doesn't exist either.
Comment #9
mikebell_ CreditAttribution: mikebell_ as a volunteer commentedI've fixed the first two issues mentioned by @jhodgdon, I'm not sure where to start with the twig files though.
The \Drupal\Core\Url class doesn't contain any reference to the drupal_get_destination() function so I've removed that from the comment.
Comment #10
jhodgdonPlease when making a new patch for an existing issue, make an interdiff file so it is clear what you changed. I have not reviewed the new patch because this wasn't done...
Leaving this at needs work for (a) interdiff file and (b) Twig files. I don't know what to tell you about the Twig template files... they need similar fixes to the rest of the url() changes that were already in the patch. The files that need fixing are username.html.twig in various directories (see comment #7).
Comment #11
AjitSThank you @jhodgdon.
Updated patch as per #8.
Interdiff is against the patch from #7.
Comment #12
jhodgdonOK, but the username.html.twig files are still not in the patch. Please fix them too.
Comment #13
imalabyaHi jennifer, have added a patch for the username.html.twig files.
Comment #14
imalabyaComment #15
jhodgdonThanks! Getting pretty close...
Hm. You don't really "pass" the options to the "options property".... Maybe we could say:
Options to set on the \Drupal\Core\Url object if linking the user's name to the user's page.
Thoughts?
Comment #16
subharanjan CreditAttribution: subharanjan commentedMade changes as per suggestions by @jhodgdon above. Thanks !
Comment #17
jhodgdonAlmost!
This template needs the same updates as the core/modules/user/templates one.
This one too.
Comment #18
subharanjan CreditAttribution: subharanjan commentedI am sorry about missing the other two instances of the same. Thanks @jhodgdon for pointing out.
Comment #19
imalabyaI think the word "the" can be wrapped in the previous line for the username.html.twig files.
Comment #20
jhodgdonYes, I think that is true about the wrapping. Otherwise, looks good!
Comment #21
imalabyaUpdated the patch
Comment #22
imalabyaComment #23
jhodgdonLooks good, thanks!
So, let's see. This patch includes user interface text changes in one place. So I think it can be applied to 8.2.x and 8.1.x. Then we will need to "backport" it to 8.0.x -- taking out the user interface text changes in file core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
So. Setting this to 8.2.x, with backport tags. Please wait until this is committed to 8.2 and 8.1 before making the 8.0 patch.
Comment #24
alexpottCommitted 750f647 and pushed to 8.0.x, 8.1.x and 8.2.x. Thanks!
I tried to find more instances where
url()
was incorrect in the codebase and I could not - nice to see this cleaned up.