Comments

yesct’s picture

Status: Active » Needs review
StatusFileSize
new6.18 KB

apply the patch 69 from #1533250: Many coding standards clean-ups in locale module first.
(this wont apply)

Status: Needs review » Needs work

The last submitted patch, 1: types_locale.2288793.1.patch, failed testing.

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new17.48 KB

this will surely conflict with the other make locale pass coder issue, but does not really need to wait on that.

this is not a thoughtful patch, just want to see what fails.

Status: Needs review » Needs work

The last submitted patch, 3: 2288793.3.patch, failed testing.

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new17.35 KB
new905 bytes

tl;dr it's an object not an array. fixed the comment and the function definition.
-------------
error was

Argument 1 passed to _locale_translation_status_debug_info() must be of the type array, object given, called in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/locale/locale.pages.inc on line 71 and defined

71 is

            'info' => _locale_translation_status_debug_info($project_info),

relevant before that:

  $status = locale_translation_get_status();

  // Prepare information about projects which have available translation
  // updates.
  if ($languages && $status) {
    foreach ($status as $project) {
      foreach ($project as $langcode => $project_info) {
        // No translation file found for this project-language combination.
        if (empty($project_info->type)) {
          $updates[$langcode]['not_found'][] = array(
            'name' => $project_info->name == 'drupal' ? t('Drupal core') : $project_data[$project_info->name]->info['name'],
            'version' => $project_info->version,
            'info' => _locale_translation_status_debug_info($project_info),
          );
          $languages_not_found[$langcode] = $langcode;
        }

project info is part of project which is part of status, status is from
$status = locale_translation_get_status();

result is an array of things... but it doesn't document it...
there $result[$project][$langcode] = $sources[$project][$langcode];

...
$sources = locale_translation_build_sources(array($project), array($langcode));

which says

 * @return array
 *   Array of source objects. Keyed by project name and language code.

so... I guess object...

yesct’s picture

Status: Needs review » Needs work
Issue tags: -coder-fixes-2012

Oh, good. it passes.
----------
1.

+++ b/core/modules/locale/locale.bulk.inc
@@ -341,8 +344,11 @@ function locale_translate_batch_refresh(array &$context) {
+ * @param bool $success
+ * @param array $results
  */
-function locale_translate_batch_finished($success, $results) {
+function locale_translate_batch_finished($success, array $results) {

needs work to add descriptions for these.

2.
also to carefully check the changes.

3.
especially to see if maybe we can say if any of these arrays are arrays of objects (particular classes).

yesct’s picture

Title: Add missing type hinting to core docblocks and typehinting for locale module » Add missing and fix some types in core docblocks and add some typehinting for locale module
Status: Needs work » Needs review
StatusFileSize
new17.41 KB
new1.01 KB

1. copied the docs from locale_translation_batch_fetch_finished since those parameters are passed through there.

2. fixed an accidental extra space in an updated comment.

3. I looked through all the changes and I dont think we can type hint any of the arrays more specifically.
===
this needs a real review.

les lim’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies. Tagging for reroll.

les lim’s picture

Issue tags: -Needs reroll
StatusFileSize
new15.67 KB

Here's the straight reroll. More detailed review to follow.

fran seva’s picture

Status: Needs work » Needs review
StatusFileSize
new15.67 KB

Rerolling #9 patch.

xlin’s picture

StatusFileSize
new2.08 KB
new16.19 KB

Under the help of mentor, we found few things need to be change.

In function locale_translation_batch_status_check(), the options array was optional but make un-optional. This change is not in the scope of the issue. Why it was needed to be made?

#10 patch add a blank before the @param bool $force in locale_translate_batch_import_files() , this is not standard. See doxygen reference: https://www.drupal.org/node/1354#order

[edit: to correct link]

yesct’s picture

Status: Needs review » Needs work
+++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php
@@ -101,10 +101,10 @@ protected function addLanguage($langcode) {
-   *   Array of source/target value translation strings. Only singular strings
-   *   are supported, no plurals. No double quotes are allowed in source and
+   *   (optional) Array of source/target value translation strings. Only singular
+   *   strings are supported, no plurals. No double quotes are allowed in source and

oops. adding (optional) made these lines go over 80 chars. Let's fix that.
----
also needs a review for the rest of the patch.

xlin’s picture

Status: Needs work » Needs review
StatusFileSize
new16.21 KB
new1.38 KB

Please review.

yesct’s picture

still applies and looks good to me. but I worked on this, so probably needs someone else to review.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me!

yesct’s picture

Component: locale.module » documentation
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/locale/locale.batch.inc
@@ -25,7 +25,7 @@
- *   Optional, an array with options that can have the following elements:
+ *   (optional) An array with options that can have the following elements:

@@ -33,7 +33,7 @@
-function locale_translation_batch_status_check($project, $langcode, $options = array(), &$context) {
+function locale_translation_batch_status_check($project, $langcode, array $options = array(), &$context) {

So this actually can not be optional since $context is mandatory and after it in the argument list. So let's remove the optional altogether. Plus $context can also be typehinted with array (as it is elsewhere in this patch)

yesct’s picture

so should the $options = array() be taken out also... if it is not optional?

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new16.28 KB
new1.13 KB

hm. maybe like this?

Status: Needs review » Needs work

The last submitted patch, 19: interdiff.2288793.13.19.patch, failed testing.

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new16.28 KB
new1 KB

oops. named the interdiff wrong in my last comment, anyway...

read the whole thing and noticed this nit about line wrapping.

jhodgdon’s picture

Status: Needs review » Needs work

Um...

+ *   An array with options that can have the following elements:
  *   - 'finish_feedback': Whether or not to give feedback to the user when the
  *     batch is finished. Optional, defaults to TRUE.
  *   - 'use_remote': Whether or not to check the remote translation file.
  *     Optional, defaults to TRUE.
+ *   Options can be an empty array, for example: array();.

That last line seems ... extraneous, because the elements each say they're optional, and I also don't think we need to tell people that "an empty array" is "for example: array()". If you think it's that important to include, then I think it should be worked into the first line of the param docs, not slapped onto the end where it's less likely to be noticed?

Also I'm concerned about:

-function locale_translation_batch_status_check($project, $langcode, $options = array(), &$context) {
+function locale_translation_batch_status_check($project, $langcode, array $options, array &$context) {

This used to have a default value of array() but now it doesn't?

Also we have a standard that if a parameter is optional, the first line of the description should say "(optional)".

And here:

+ * @return array|bool
+ *   The batch structure, or FALSE if no files used to build the batch.

This is missing the word "are"... if no files [ARE] used to...

The rest looks good...

yesct’s picture

yeah, the removal of the default (and moving it to the awkward line in the docs is because of @alexpott 's comment #17.

So it is essentially making it not optional. We didn't have any uses in core of it being optional (not specified).
Reordering the arguments .. is a bit more than just typehinting so sounds like a separate issue to me.

Yeah, the are thing makes sense.

jamesdixon’s picture

I am on this.

jamesdixon’s picture

StatusFileSize
new16.46 KB
new1.46 KB

Here's my attempt at updating the documentation based on the feedback provided. I added (optional) in front of finish_feedback and use_remote instead of having them at the end.

I've removed the last line saying options can be an empty array.

jamesdixon’s picture

Status: Needs work » Needs review
jamesdixon’s picture

I'm going to take a couple things out of the patch and create a new issue for some of it as recommended by YesCT.

jamesdixon’s picture

Status: Needs review » Needs work
jhodgdon’s picture

So... this issue is not really just documentation? perhaps change the component?

jamesdixon’s picture

I've created a new issue for rearranging the order of the arguments in locale_translation_batch_status_check:

https://www.drupal.org/node/2359615

jamesdixon’s picture

Status: Needs work » Needs review
StatusFileSize
new15.16 KB
new1.2 KB

Here's the proposed patch. I've removed the documentation updates from locale_translation_batch_status_check as it needs some work in the issue that was just created regarding the argument reordering.

alexpott’s picture

Status: Needs review » Needs work

Sorry but I've just closed #2359615: function locale_translation_batch_status_check has an optional argument before a mandatory argument in the function definition and explained on that issue why reordering the arguments is not possible and why the $options argument can not possible be optional.

jamesdixon’s picture

Component: documentation » locale.module

@alexpott: I apologize I misunderstood when creating that issue. I'll just change the component from documentation to locale.module and make the options argument no longer optional.

jamesdixon’s picture

Status: Needs work » Needs review
StatusFileSize
new16.2 KB
new975 bytes

I've updated the options argument in locale_translation_batch_status_check so it is no longer optional and changed the documentation to reflect this. Here's the next patch.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me. Thanks for sticking with it @jamesdixon.

+++ b/core/modules/locale/locale.batch.inc
@@ -25,7 +25,7 @@
  * @param array $options
- *   Optional, an array with options that can have the following elements:
+ *   An array with options that can have the following elements:

The $options argument is itself not actually optional because of how the batch system works. Both the elements it can contain are optional and that fact is documented.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 4cdd94b on 8.0.x
    Issue #2288793 by YesCT, jamesdixon, xq1003, fran seva, Les Lim: Add...

Status: Fixed » Closed (fixed)

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