Updated: Comment #N

Problem/Motivation

In #1497230: Use Dependency Injection to handle object definitions we introduced a basic Language class to keep backwards compatibility with stdClass. In order to keep that simple we did not rename the methods and the properties. Noticed while reviewing #1512424: Add a LanguageInterface, and property setters/getters to Language class.

Proposed resolution

Clean up the language class.

The notes, hints for patchers and hints for reviewers in #2016679: Expand Entity Type interfaces to provide methods, protect the properties might provide more insight here. This is not strickly a child of that meta, but it is doing something similar, so we can consult that meta issue summary and even some of the child issues for understanding.

Remaining tasks

  • Change method names and class properties of the Language class to use lowerCamel naming.
  • Do a search and replace for updating all Language::WHATEVER_CONST's to LanguageInterface::WHATEVER_CONST's.
  • Create and post a patch (https://drupal.org/node/707484).

User interface changes

None.

API changes

?

Not a beta deadline.

Follow-up from #1512424: Add a LanguageInterface, and property setters/getters to Language class.

CommentFileSizeAuthor
#308 2226533.308.patch4.77 KBtstoeckler
#306 2226533.306.patch5.02 KBYesCT
#305 2226533.305.patch5.02 KBYesCT
#291 2226533.291.patch257.13 KBYesCT
#291 interdiff.2226533.288.291.txt15.15 KBYesCT
#288 2226533.288.patch269.94 KBYesCT
#286 2226533.286.patch276.46 KBYesCT
#282 interdiff.2226533.281.283b-setId.txt1.39 KBYesCT
#282 interdiff.2226533.281.283a-directidfrom2188675.txt2.29 KBYesCT
#282 2226533.282.patch276.44 KBYesCT
#281 interdiff-2226533-279-281.txt500 bytesYesCT
#281 2226533.281.patch273.96 KBYesCT
#279 interdiff-conflicts-277.txt25.25 KBYesCT
#279 2226533.279.patch273.76 KBYesCT
#277 2226533.277.patch282.95 KBYesCT
#275 interdiff.274.275.txt2.2 KBChris Dart
#275 2226533.275.patch282.37 KBChris Dart
#274 MakeSure.php.txt143 bytesjmolivas
#274 MakeSureTest.php.txt214 bytesjmolivas
#274 interdiff.272.274.txt2.64 KBjmolivas
#274 2226533.274.patch280.61 KBjmolivas
#272 2226533.272.patch279.15 KBalexpott
#272 269-272-interdiff.txt987 bytesalexpott
#269 2226533.269.patch277.9 KBYesCT
#267 2226533.267.patch278.77 KBYesCT
#261 2226533.261.patch278.75 KBYesCT
#259 2226533.259.patch280.21 KBmartin107
#259 interdiff-257-259.txt616 bytesmartin107
#257 2226533.257.patch279.61 KBmartin107
#253 interdiff-251-253.txt1.16 KBmartin107
#253 2226533.253.patch279.64 KBmartin107
#251 2226533.251.patch280.08 KBmartin107
#250 2226533.250.patch280.65 KBYesCT
#248 2226533.248.patch281.45 KBmartin107
#244 interdiff-242-244.txt1.09 KBmartin107
#244 2226533.244.patch281.46 KBmartin107
#242 2226533.242.patch280.58 KBmartin107
#240 interdiff-conflictdiff.txt1.82 KBYesCT
#240 2226533.240.patch281.43 KBYesCT
#238 2226533.238.patch281.45 KBmartin107
#235 2226533.235.patch281.84 KBmartin107
#234 2226533.234.patch281.76 KBmartin107
#234 interdiff-232-234.txt721 bytesmartin107
#232 2226533.232.patch281.31 KBmartin107
#232 interdiff-230-232.txt404 bytesmartin107
#230 2226533.230.patch281.42 KBmartin107
#228 interdiff.2226533.226.227.txt1.95 KBYesCT
#228 2226533.227.patch281.41 KBYesCT
#226 2226533.226.patch282.73 KBYesCT
#223 interdiff-typos.txt1.63 KBYesCT
#223 2226533.223.patch282.74 KBYesCT
#222 interdiff-219-222.txt27.7 KBmartin107
#222 2226533_222.patch277.28 KBmartin107
#219 interdiff.2226533.213.219.txt12.1 KBYesCT
#219 2226533_219.patch304.98 KBYesCT
#213 interdiff-211-213.txt664 bytesmartin107
#213 2226533_213.patch310.44 KBmartin107
#211 2226533_211.patch310.21 KBmartin107
#207 conflict-resolved-diff.txt5.19 KBYesCT
#207 2226533_207.patch310.19 KBYesCT
#201 2226533_201.patch310.27 KBmartin107
#199 interdiff-197.199.txt803 bytesmartin107
#199 2226533_199.patch282.89 KBmartin107
#197 2226533_197.patch283.01 KBmartin107
#197 interdiff-195-197.txt667 bytesmartin107
#195 interdiff-192-195.txt616 bytesmartin107
#195 2226533_195.patch283.48 KBmartin107
#192 2226533_191.patch283.48 KBmartin107
#191 2226533_191.patch283.48 KBmartin107
#191 interdiff-188-191.txt1.02 KBmartin107
#188 2226533_188.patch283.48 KBmartin107
#188 interdiff-185-188.txt1.81 KBmartin107
#185 2226533_185.patch282.57 KBmartin107
#183 interdiff-181-183.txt2.27 KBmartin107
#183 2226533_183.patch284.6 KBmartin107
#181 2226533_181.patch282.64 KBmartin107
#179 interdiff-177-179.txt681 bytesmartin107
#179 2226533_179.patch283.37 KBmartin107
#177 2226533_177.patch283.37 KBmartin107
#175 interdiff-173-175.txt714 bytesmartin107
#175 2226533_175.patch283.35 KBmartin107
#173 2226533_173.patch282.87 KBmartin107
#170 2226533_170.patch282.74 KBmartin107
#167 interdiff-165-167.txt1.24 KBmartin107
#167 2226533_167.patch284.47 KBmartin107
#165 2226533_165.patch285.71 KBmartin107
#165 interdiff-162-165.txt549 bytesmartin107
#164 interdiff-160-162.txt24.66 KBmartin107
#162 2226533_162.patch285.99 KBmartin107
#160 2226533_160.patch308.59 KBmartin107
#155 2226533_155.patch501.19 KBmartin107
#153 2226533_153.patch516.86 KBmartin107
#151 interdiff-147-151.txt733 bytesmartin107
#151 2226533_151.patch516.81 KBmartin107
#147 2226533_147.patch515.4 KBfilijonka
#145 2226533_145.patch516.26 KBfilijonka
#143 2226533_143.patch516.22 KBfilijonka
#143 interdiff-2226533-141-143.txt840 bytesfilijonka
#141 2226533_141.patch515.55 KBfilijonka
#141 interdiff-2226533-129-141.txt1.8 KBfilijonka
#133 2226533_133.patch59.72 KBmartin107
#133 interdiff-129-133.txt8.91 KBmartin107
#129 2226533_129.patch515.26 KBmartin107
#129 interdiff-126-129.txt1.29 KBmartin107
#126 2226533_125.patch515.18 KBmartin107
#126 interdiff-122-125.txt768 bytesmartin107
#122 2226533_122.patch515.12 KBmartin107
#120 2226533_120.patch513.02 KBfilijonka
#118 2226533_118.patch514.53 KBfilijonka
#118 interdiff-2226533-116-118.txt1.63 KBfilijonka
#116 2226533_116.patch514.87 KBfilijonka
#116 interdiff-2226533-113-116.txt5.05 KBfilijonka
#113 2226533_112.patch516.36 KBfilijonka
#113 interdiff-2226533-110-112.txt3.33 KBfilijonka
#110 2226533_110.patch516.39 KBfilijonka
#110 interdiff-2226533-107-110.txt1.13 KBfilijonka
#104 interdiff-2226533-101-104.txt1.2 KBYesCT
#104 2226533_104.patch517.7 KBYesCT
#101 2226533_100.patch516.58 KBfilijonka
#101 interdiff-2226533-98-100.txt500 bytesfilijonka
#98 2226533_98.patch516.58 KBfilijonka
#98 interdiff-2226533-94-98.txt8.78 KBfilijonka
#94 2226533_94.patch521.05 KBfilijonka
#94 interdiff-2226533-92-94.txt401 bytesfilijonka
#92 2226533_92.patch521.1 KBfilijonka
#92 interdiff-2226533-89-92.txt7.18 KBfilijonka
#89 2226533_89.patch516.11 KBfilijonka
#89 interdiff-2226533-87-89.txt12.61 KBfilijonka
#87 interdiff-85-87.txt5 KBmartin107
#87 languageChanges-2226533-87.patch507.33 KBmartin107
#85 interdiff-83-85.txt3.41 KBmartin107
#85 languageChanges-2226533-85.patch505.88 KBmartin107
#83 languageChanges-2226533-82.patch504.42 KBmartin107
#83 interdiff-75-82.txt8.49 KBmartin107
#83 interdiff-75-tidy.txt1.55 KBmartin107
#83 interdiff-75-locked.txt1.8 KBmartin107
#83 interdiff-75-getters.txt5.14 KBmartin107
#77 interdiff-75-77.txt5.73 KBmartin107
#77 languageChanges-2226533-77.patch500.44 KBmartin107
#75 interdiff-73.75.txt1.52 KBmartin107
#75 languageChanges-2226533-75.patch497.05 KBmartin107
#73 2226533_filijonka.patch494.84 KBfilijonka
#73 interdiff-2226533-71-filijonka.txt5.94 KBfilijonka
#71 2226533_71.patch493.83 KBmartin107
#62 2226533_61.patch494.28 KBmartin107
#61 2226533_61.patch493.69 KBmartin107
#56 2226533_56.patch493.01 KBfilijonka
#53 2226533_53.patch493.94 KBfilijonka
#53 interdiff-2226533-47-53.txt10.11 KBfilijonka
#49 2226533_49.patch495.29 KBfilijonka
#49 interdiff-2226533-47-49.txt10.67 KBfilijonka
#47 2226533_47.patch486.53 KBfilijonka
#47 interdiff-2226533-44-47.txt11.11 KBfilijonka
#45 2226533_44.patch482.09 KBfilijonka
#45 interdiff-2226533-43-44.txt5.84 KBfilijonka
#43 drupal_2226533_43.patch482.73 KBXano
#43 interdiff.txt2.99 KBXano
#40 drupal_2226533_40.patch475.92 KBXano
#40 interdiff.txt3.47 KBXano
#39 drupal_2226533_39.patch473.6 KBXano
#36 2226533_35.patch473.83 KBfilijonka
#34 drupal_2226533_34.patch474.3 KBXano
#34 interdiff.txt6.06 KBXano
#32 drupal_2226533_32.patch474.18 KBXano
#32 interdiff.txt883 bytesXano
#30 drupal_2226533_30.patch474.15 KBXano
#30 interdiff.txt26.13 KBXano
#27 drupal_2226533_27.patch453.93 KBXano
#27 interdiff.txt698 bytesXano
#25 drupal_2226533_25.patch453.94 KBXano
#25 interdiff.txt49.12 KBXano
#23 drupal_2226533_23.patch423.7 KBXano
#23 interdiff.txt254.3 KBXano
#21 drupal_2226533_21.patch172.23 KBXano
#16 interdiff.txt21.62 KBXano
#16 drupal_2226533_16.patch174.55 KBXano
#14 interdiff.txt6.5 KBXano
#14 drupal_2226533_14.patch155.4 KBXano
#11 interdiff.txt52.14 KBXano
#11 drupal_2226533_11.patch148.28 KBXano
#8 interdiff.txt79.12 KBXano
#8 drupal_2226533_8.patch91.04 KBXano
#5 drupal_2226533_5.patch3.21 KBvisabhishek
#3 drupal_2226533_3.patch4.3 KBXano
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

csg’s picture

Assigned: Unassigned » csg
csg’s picture

Status: Active » Postponed
Xano’s picture

Status: Postponed » Needs review
FileSize
4.3 KB

Let's see what this breaks.

Status: Needs review » Needs work

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

visabhishek’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

Lets Check this one

Status: Needs review » Needs work

The last submitted patch, 5: drupal_2226533_5.patch, failed testing.

Xano’s picture

@visabhishek: that is not the goal behind this issue. All methods are to become public. If calling code fails because of this, that means it will need to be refactored to use the LanguageInterface getter and setter methods instead.

Also, whenever you post a patch that is not the first in an issue and is not a re-roll, please provide an interdiff.

Xano’s picture

Assigned: csg » Unassigned
Status: Needs work » Needs review
FileSize
91.04 KB
79.12 KB

Status: Needs review » Needs work

The last submitted patch, 8: drupal_2226533_8.patch, failed testing.

Xano’s picture

@visabhishek: The patch from #8 is roughly how to solve this. It replaces many, but not all calls to the former public properties on \Drupal\Core\Language\Language with calls to the methods on \Drupal\Core\Language\LanguageInterface. Apart from converting any remaining property access, we will also need to convert type hints to \Drupal\Core\Language\Language to \Drupal\Core\Language\LanguageInterface

Xano’s picture

Status: Needs work » Needs review
FileSize
148.28 KB
52.14 KB
visabhishek’s picture

@Xano: Thanks for the IDEA, i will try to resolve this

Xano’s picture

Status: Needs work » Needs review
FileSize
155.4 KB
6.5 KB

This patch should at least make sure Drupal can be installed, which makes debugging easier.

Xano’s picture

Status: Needs work » Needs review
FileSize
174.55 KB
21.62 KB
YesCT’s picture

Issue summary: View changes

@visabhishek the notes, hints for patchers and hints for reviewers in #2016679: Expand Entity Type interfaces to provide methods, protect the properties might provide more insight here. This is not strickly a child of that meta, but it is doing something similar, so we can consult that meta issue summary and even some of the child issues for understanding.

Xano’s picture

16: drupal_2226533_16.patch queued for re-testing.

Xano’s picture

FileSize
172.23 KB
tstoeckler’s picture

Hm.. I wasn't aware of this issue :-/ It seems it in part duplicates #2246665: Typehint with Drupal\Core\Language\LanguageInterface instead Drupal\Core\Language\Language (or I suppose the other way around, but whatever...)

Xano’s picture

Status: Needs work » Needs review
FileSize
254.3 KB
423.7 KB

This issue is about completely replacing references to the class with references to the interface, where appropriate.

PHPUnit tests pass locally. Let's see what Simpletest does.

Status: Needs review » Needs work

The last submitted patch, 23: drupal_2226533_23.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
49.12 KB
453.94 KB

Status: Needs review » Needs work

The last submitted patch, 25: drupal_2226533_25.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
698 bytes
453.93 KB

Status: Needs review » Needs work

The last submitted patch, 27: drupal_2226533_27.patch, failed testing.

Xano’s picture

\Drupal\Core\Language\Language::sort() is a tricky piece of code that only works on arrays of languages that have the same properties as the default class.

Xano’s picture

Status: Needs work » Needs review
FileSize
26.13 KB
474.15 KB
Xano’s picture

Status: Needs work » Needs review
FileSize
883 bytes
474.18 KB
Xano’s picture

Status: Needs work » Needs review
FileSize
6.06 KB
474.3 KB
filijonka’s picture

Status: Needs work » Needs review
FileSize
473.83 KB

reroll of #34. couldn't get an interdiff.

filijonka’s picture

ah there was a old function name left. will fix that tomorrow.

Xano’s picture

Status: Needs work » Needs review
FileSize
473.6 KB

Mix-up with another patch? Here's a proper re-roll of #34.

Xano’s picture

FileSize
3.47 KB
475.92 KB
Xano’s picture

Status: Needs work » Needs review
FileSize
2.99 KB
482.73 KB
filijonka’s picture

Status: Needs work » Needs review
FileSize
5.84 KB
482.09 KB

Just needed to reroll, waiting for the test to finish which I expect to fail actually...and after that begin to sort the tests that are failing

Status: Needs review » Needs work

The last submitted patch, 45: 2226533_44.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
11.11 KB
486.53 KB

Still some stuff that needs to be changed. There seems to be a lack of get/set for the locked property which is needed.

filijonka’s picture

Status: Needs work » Needs review
FileSize
10.67 KB
495.29 KB

another patch that won't go through but hopefully there is only one issue left that has to do with the LanguageInterface and that is the lack of get/set functions for property locked.

All other failings are not due to this change...

filijonka’s picture

Status: Needs work » Needs review

49: 2226533_49.patch queued for re-testing.

oh sorry apparently missed head by some inches so rerolling this patch

filijonka’s picture

Status: Needs work » Needs review
FileSize
10.11 KB
493.94 KB

reroll of 47 and applying the changes I made for patch 49

filijonka’s picture

filijonka’s picture

FileSize
493.01 KB

reroll of #53, couldn't get an interdiff at the moment. Think something is seriously wrong with this since a lot of errors is coming from tests that has nothing to do with languageinterface to do

filijonka’s picture

Status: Needs work » Needs review
filijonka’s picture

ok well this is kinda irritating and impossible when whatever new patch committed to core invalidate this patch.

is there a way to strip down this patch into smaller once?

rodrigoaguilera’s picture

I think you should assign this issue to yourself aslong as you are working on it

martin107’s picture

Status: Needs work » Needs review
FileSize
493.69 KB

Reroll.

martin107’s picture

FileSize
494.28 KB

Looking to override #61 with fixes

YesCT’s picture

@martin107 if you can get into irc and join #drupal-contribute that would be awesome.

The last submitted patch, 61: 2226533_61.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 62: 2226533_61.patch, failed testing.

YesCT’s picture

#61 failed with

Fatal error: Cannot access protected property Drupal\Core\Language\Language::$id in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/user/user.install on line 223

and the interdiff for 61 and 62 is in user.install:

> -  $langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
> +  $langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();

seems reasonable. :)

----
now #62
has
Drupal\comment\Tests\CommentTranslationUITest 127 passes 52 fails 11 exceptions
Drupal\config_translation\Tests\ConfigTranslationUiThemeTest 15 passes 3 fails 1 exceptions
Drupal\config_translation\Tests\ConfigTranslationViewListUiT 30 passes 3 fails 1 exceptions
Drupal\config_translation\Tests\ConfigTranslationListUiTest 114 passes 32 fails 6 exceptions
Drupal\config_translation\Tests\ConfigTranslationOverviewTes 55 passes 12 fails 3 exceptions
Drupal\content_translation\Tests\ContentTestTranslationUITes 95 passes 55 fails 12 exceptions
Drupal\content_translation\Tests\ContentTranslationWorkflows 147 passes 12 fails 4 exceptions
Drupal\content_translation\Tests\ContentTranslationSettingsT 112 passes 2 fails 1 exceptions
Drupal\custom_block\Tests\CustomBlockTranslationUITest 105 passes 50 fails 11 exceptions

and then...

Drupal\system\Tests\Entity\EntityUUIDTest 88 passes

Fatal error: Call to a member function getString() on a non-object in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php on line 597
FATAL Drupal\config_translation\Tests\ConfigTranslationUiTest: test runner returned a non-zero error code (255).

and

Drupal\file\Tests\RemoteFileSaveUploadTest 254 passes

Fatal error: Cannot access protected property Drupal\Core\Language\Language::$locked in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php on line 64
FATAL Drupal\system\Tests\Form\LanguageSelectElementTest: test runner returned a non-zero error code (255).
Drupal\system\Tests\Form\FormObjectTest 43 passes

...
and more...

YesCT’s picture

we should probably use id(), not getId(), until #2246695: replace all core usages of id() with getid() is resolved.

filijonka’s picture

@yesct if you keep on looking for the fatal erros in #62 which seems to pretty the same as I have there are some of them questionable if they really are language based.

about the id and getid. in the issue you referenced to if you read my comment again you'll see that I point out that in quite a lot of issues for creating get/set functions people have used id() + getid() and some cases only getid().

martin107’s picture

I've had a careful look at the difference between #56 and #62 nothing jumps out to explain my failed rebase ....

Looking at CommentTranslationUITest there are two exceptions :-

Exception Notice     ContentTranslatio  208 Drupal\content_translation\Tests\Co
    Undefined index:
    itDrupal\content_translation\Tests\ContentTranslationUITest->doTestAuthoringInfo()
    Drupal\content_translation\Tests\ContentTranslationUITest->testTranslationUI()
    Drupal\simpletest\TestBase->run()
    simpletest_script_run_one_test('1',
    'Drupal\comment\Tests\CommentTranslationUITest')

and

Exception Notice     ContentTranslatio  209 Drupal\content_translation\Tests\Co
    Undefined index:
    frDrupal\content_translation\Tests\ContentTranslationUITest->doTestAuthoringInfo()
    Drupal\content_translation\Tests\ContentTranslationUITest->testTranslationUI()
    Drupal\simpletest\TestBase->run()
    simpletest_script_run_one_test('1',
    'Drupal\comment\Tests\CommentTranslationUITest')

both cases relating to bad offsets "it" and "fr" in an piece of code like :-

$entity->translation[$langcode]['uid']

$langcode is the bad offset

This was saved by ( that is a language_save() ) in ContentTranslationTestBase::setupLanguages()

So something in the save/read is not longer working .. hmm

It late on Friday night for me ... it might be slow to unpick my mistakes...and this might be just one of many errors.
I will look at this again on Sunday ... sorry I can't look at it on Saturday

YesCT’s picture

oh, I thought this was adding getId().
It's not! :) Sorry. So using getId() seems fine in this issue.

martin107’s picture

Status: Needs work » Needs review
FileSize
493.83 KB

The reroll lasted less than 24 hours! This is a reroll of #62

I think I have made better choices this time...in the area of ContentTranslaionManagerAccessCheck::access() .. Here is what it would look like after patch

      switch ($operation) {
        case 'create':
          $source = language_load($source) ?: $entity->language();
          $target = language_load($target) ?: \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
          return ($source->getId() != $target->getId()
            && isset($languages[$source->getId()])
            && isset($languages[$target->getId()])
            && !isset($translations[$target->getId()])
            && $controller->getTranslationAccess($entity, $operation))
            ? static::ALLOW : static::DENY;

        case 'update':
        case 'delete':
          $language = language_load($language) ?: \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
          return isset($languages[$language->getId()])
            && $language->getId() != $entity->getUntranslated()->language()->getId()
            && isset($translations[$language->getId()])
            && $controller->getTranslationAccess($entity, $operation)
            ? static::ALLOW : static::DENY;
      }

Please shout if anything seems obviously wrong.

Let's see what testbot thinks...

Also from review in #66 - Fatal error: Cannot access protected property Drupal\Core\Language\Language::$locked ..
That look like an isolated problem which could be cherry picked but I am leaving this as a straight reroll just to avoid confusion

Status: Needs review » Needs work

The last submitted patch, 71: 2226533_71.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
5.94 KB
494.84 KB

hi thanks for working on this @martin107, 24h is actually quite long time in this issue.

ehm was going to point out the small problems but I did a new patch continueing the work I had done simply cause I wanted to know what was going on. added that patch to a test issue to see what happends and it turned out to have the similar problems that patch in 71 have.
After a chatt with @yesct she suggested to diff my patch and #71 + ul the patch.

This patch will fail as #71 on same fatal errors, getvalue and getstring. and as earlier a lot of language tests are failing.

Status: Needs review » Needs work

The last submitted patch, 73: 2226533_filijonka.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
497.05 KB
1.52 KB

No major fix - Correcting access to protected properties. Reduces the exception count a bit.

Status: Needs review » Needs work

The last submitted patch, 75: languageChanges-2226533-75.patch, failed testing.

martin107’s picture

More issues fixed in the same vein as #75

except in answer to reported error "Undefined LanguageInterface"

-  $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
+  $language_content = \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT);

Others might think this is really saying the "use" statement was missing from the top of the file!

martin107’s picture

Status: Needs work » Needs review
YesCT’s picture

this is taking out the only usage (besides the test) of sortByWeightAndTitleKey()
why?
patch #30 was the one to introduce the change
in core/lib/Drupal/Core/Language/Language.php

-  public static function sort(&$languages) {
-    uasort($languages, 'Drupal\Component\Utility\SortArray::sortByWeightAndTitleKey');
+  public static function sort(LanguageInterface $a, LanguageInterface $b) {
+    if ($a->getWeight() == $b->getWeight()) {
+      return strnatcasecmp($a->getName(), $b->getName());
+    }
+    else {
+      return $a->getWeight() < $b->getWeight() ? -1 : 1;
+    }

adding some sort related issues.

also, if the typehint issue gets in first, this should be easier to review. adding it as related.

Status: Needs review » Needs work

The last submitted patch, 77: languageChanges-2226533-77.patch, failed testing.

YesCT’s picture

+++ b/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationOverviewAccess.php
@@ -69,7 +69,7 @@ public function access(Route $route, Request $request, AccountInterface $account
-      !$this->sourceLanguage->locked;
+      !$this->sourceLanguage->isocked();

+++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php
@@ -455,7 +455,7 @@ public function searchFormAlter(array &$form, array &$form_state) {
-      $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
+      $language_options[$langcode] = $language->islocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();

I think these should both be isLocked()

filijonka’s picture

been discussing this with @yesct and I think that the best approach to the Language::sort is to let it be as it is on head instead of the changes this patch is doing. simply because there are issues like #2239399: Languages should be sorted by label instead of title dealing with this.

The tests are written for that solution and if we change it and doesn't change the tests they are going to fail.

martin107’s picture

Status: Needs work » Needs review
FileSize
5.14 KB
1.8 KB
1.55 KB
8.49 KB
504.42 KB

Breaking this interdiff into stages for review

1) As testing get further .. exposed more issues with accessing protected properties..interdiff-75-getters.txt

2) Fixed #81 ( hanging my head -- sorry for the distraction ) ...interdiff-75.locked.txt

3) Credit to filijonka for this code tidy ... interdiff-75-tidy.txt

Status: Needs review » Needs work

The last submitted patch, 83: languageChanges-2226533-82.patch, failed testing.

martin107’s picture

Assigned: Unassigned » martin107
Status: Needs work » Needs review
FileSize
505.88 KB
3.41 KB

1) Fixed more access to protected methods ... via getters.

2) No more white space.

I will sit on this .. until it goes green

Status: Needs review » Needs work

The last submitted patch, 85: languageChanges-2226533-85.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
507.33 KB
5 KB

Corrected a few more $language->getName() and $language->isLocked()

Ahem should have used search/replace for this a bit sooner.

Status: Needs review » Needs work

The last submitted patch, 87: languageChanges-2226533-87.patch, failed testing.

filijonka’s picture

FileSize
12.61 KB
516.11 KB

tried the reverting this back to using the language::sort that is on head and that created a lot of errors.
basicly all test just gave that sort(null) instead of sort(array of languages).

So let's ignore that for now and see where we end up when it's green. perhaps these issues dealing with this function is sorted out by then.

this is yet another patch for the changing that we have begun.

filijonka’s picture

Status: Needs work » Needs review

ooh needs review...silly moi

Status: Needs review » Needs work

The last submitted patch, 89: 2226533_89.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
7.18 KB
521.1 KB

The error above was caused by a check in language.module saying if(!empty($language->locked)) which I changed to correct function but since locked is a boolesk variable it should be sufficient to just do if(!$language->isLocked())

fixed that and did some more changes..

Status: Needs review » Needs work

The last submitted patch, 92: 2226533_92.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
401 bytes
521.05 KB

hmm had added a whitespace by accident and hopefully that was the reason for prev. failure.

I noticed somewhere that we had a line saying $language->direction ? ... : ...; and that was changed to getDirection.
but direction isn't a boolesk variable and afaik never has.

So my guess is that we're getting close to a good result but there are probalby some logical errors involved too.

Status: Needs review » Needs work

The last submitted patch, 94: 2226533_94.patch, failed testing.

filijonka’s picture

yes this is a logcial error that turns up. working on it..

martin107’s picture

I have a fix for one of the test errors....from #87 ( Drupal\node\Tests\NodeTokenReplaceTest )

this->languageInterface->id becomes this->languageInterface->getId() in two places see below..

I will leave it here so we can come back to it.

But it highlights some non-core standard code...

$this->languageInterface->getId() !!!! ($languageInterface needs a name change )

There has been some discussion about how to reduce the size of the patch ... I will file a minor issue just for the name change.
rather than making our lives harder ( PS #2270339: $languageInterface is a misleading variable name in TokenReplaceUnitTestBase )

--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -89,7 +89,7 @@ function testNodeTokenReplacement() {
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
 
     foreach ($tests as $input => $expected) {
-      $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->id));
+      $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->getId()));
       $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input)));
     }
 
@@ -101,7 +101,7 @@ function testNodeTokenReplacement() {
     $tests['[node:author:name]'] = $account->getUsername();
 
     foreach ($tests as $input => $expected) {
-      $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->id, 'sanitize' => FALSE));
+      $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->languageInterface->getId(), 'sanitize' => FALSE));
       $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
     }
filijonka’s picture

Status: Needs work » Needs review
FileSize
8.78 KB
516.58 KB

reverted some of the previous changes made by me and did some more changes.

Status: Needs review » Needs work

The last submitted patch, 98: 2226533_98.patch, failed testing.

filijonka’s picture

some of the current errors seems to be due to the tricky part that we have two different kind of language interfaces. one in module and one in core.

filijonka’s picture

Status: Needs work » Needs review
FileSize
500 bytes
516.58 KB

Status: Needs review » Needs work

The last submitted patch, 101: 2226533_100.patch, failed testing.

martin107’s picture

1) Just wanted to comment for the record that #98 slips in the fixes from #97 thank you.( I was just about to do that )
NodeTokenReplaceTest is now green..

2) Its been suggest on IRC that I keep this issue updated with the concepts being developed as common currency in #2270339: $languageInterface is a misleading variable name in TokenReplaceUnitTestBase

$languageInterface is being replaced by $interfaceLanguage

As a way differentiate between the two

A) $interfaceLanguage the interface settings being used for the test and created :-
$this->languageInterface = \Drupal::languageManager()->getCurrentLanguage();

B) LanguageInterface:( @see \Drupal\Core\Language\LanguageInterface AND \Drupal\language\LanguageInterface )

As always naming things is hard, and the more eyes on this the better... so please direct comments to the other issue. I am aiming to put the other issue to bed soon after the 22nd of May

YesCT’s picture

Status: Needs work » Needs review
FileSize
517.7 KB
1.2 KB

1.
#101 looks right, cause that language is a LanguageEntity which is a language/LanguageInterface (configurable)
which #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface will help clarify.
but we should probably revert it all the way back to what it was.

doing that.

2.
also,
fixing the typo
gtetId
from #89

Status: Needs review » Needs work

The last submitted patch, 104: 2226533_104.patch, failed testing.

YesCT’s picture

Would have thought that would have fixed more than one fail.
Maybe the gtegId is in a section of code that isn't used, or isn't tested?

filijonka’s picture

@yesct the reason for at least 140 of these fail and probably more is that in the language.module there are using both of the languageinterfaces. So sometimes it uses Drupal\Core\Language and sometimes it uses Drupal\Language\Language(?) Not sure I got the last one correct but basicly it means that sometimes it is e.g ->getId() and othertimes its ->id.

That is what I'm doing at the moment to figure out these errors.

martin107’s picture

Status: Needs work » Needs review
FileSize
517.72 KB

Patch no longer applies ( this is just a straight reroll - lots of merging, auto merging and 2 trivial conflicts to resolve )

So that patch lasted about 4 hours -- Who knew Europe would wake up and go on a commit spree...

Status: Needs review » Needs work

The last submitted patch, 108: languageChanges-2226533-107.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
1.13 KB
516.39 KB

just reverted back some of the changes made in language module. went it through and think this would make it much better. i hope

martin107’s picture

So I hope to shine a spotlight on the ->getId() versus ->id debate - As it too is kicking me in the bum.

Looking at the recent conversion of book_language_entity_delete ( see book.module )

the function argument when I followed it back to its source function .. takes me to \Drupal\language\Entity\Language
where the magic getter function facilitates access to the id :-

  public function get($property_name) {}

So that should be reverted along with a few others I can see...

This is opposed to code of the form

\Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId()

where the getId() can be traced to \Drupal\Core\Language\LanguageInterface. An separate Interface.

PS sorry cross post filijonka has beaten me to the fix

Status: Needs review » Needs work

The last submitted patch, 110: 2226533_110.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
3.33 KB
516.36 KB
filijonka’s picture

as soone as this test is done there will be a new patch which solves a big amount of errors I think.

Status: Needs review » Needs work

The last submitted patch, 113: 2226533_112.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
5.05 KB
514.87 KB

Status: Needs review » Needs work

The last submitted patch, 116: 2226533_116.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
1.63 KB
514.53 KB

made also sure it's still on head

Status: Needs review » Needs work

The last submitted patch, 118: 2226533_118.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
513.02 KB

reroll

Status: Needs review » Needs work

The last submitted patch, 120: 2226533_120.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
515.12 KB

As advised by filijonka this reroll is based on #118

Lots of merging, auto-merging and conflicts in rebase ...

Mostly this is a happy reroll because the side issue raised in #103 has landed in core.

The $languageInterface is being replaced by $interfaceLanguage issue.

5 conflicts in this reroll led to the selection of 4 tests for local testing as always testbot will give a more complete answer ...

php core/scripts/run-tests.sh  --url http://dev.drupal.co.uk --verbose --file ./core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php
php core/scripts/run-tests.sh  --url http://dev.drupal.co.uk --verbose --file ./core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php
php core/scripts/run-tests.sh  --url http://dev.drupal.co.uk --verbose --file ./core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
php core/scripts/run-tests.sh  --url http://dev.drupal.co.uk --verbose --file ./core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php

So the target is is back to the 48 fails of #118...

PS

I have been asked by the community to ensure that the distinction between ->id and ->getId is preserved, and is a concern myself...
The answer is it an ongoing thing that will come out right in the wash....

There are drives in separate issues show clear differences between

\Drupal\Core\Language\LanguageInterface and \Drupal\language\Entity\Language

When these initiatives are complete and have caused more 'Happy Rerolls' here then I will take the time to visual inspect this monster of a patch and post further comments

PPS see the fail below.... test bot reports out of memory errors will force retest again soon....

Status: Needs review » Needs work

The last submitted patch, 122: 2226533_122.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review

122: 2226533_122.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 122: 2226533_122.patch, failed testing.

martin107’s picture

Assigned: martin107 » Unassigned
FileSize
768 bytes
515.18 KB

I am at the limit of what I can do tonight... so I am just pushing the obvious fix.

I am "unassigning" but not changing the amount I work on this .. I am still committed to lurking on this until its is green and stable.

BUT because YesCT and filijonka are working on this just as hard and I don't want to permanently signal that I am always working at this moment
I will try some more in about 12 hours.

martin107’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 126: 2226533_125.patch, failed testing.

martin107’s picture

FileSize
1.29 KB
515.26 KB

Drupal\locale\Tests\LocaleContentTest now passes.

As a side note I have changed a local variable $language_interface to become $interface_language ( it holds a language object not an interface )
I know it should be $interfaceLangauge but then it would be out of keeping with the other un-CamelCased local variables in the file!

martin107’s picture

Status: Needs work » Needs review

triggering testbot

Status: Needs review » Needs work

The last submitted patch, 129: 2226533_129.patch, failed testing.

filijonka’s picture

ok so now back to 40 fails, different between this and #87 are that errors like fatal errors on getString and getValue are gone. Which was what I hoped for but also hoped that we would be a little be less than 40.

martin107’s picture

Status: Needs work » Needs review
FileSize
8.91 KB
59.72 KB

Cherry picking something obvious resulted in

./core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php going green

Interface constants should be ONLY pulled from the interface directly not through an intermediate object

So changes are an iterations of the form

-    $field = $entity->getTranslation(Language::LANGCODE_DEFAULT)->get($this->field_name);
+    $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->field_name);

PS I used git diff -M to create the patch .. but I am a bit suspicious about the file size ( 50kb versus 500kb )

filijonka’s picture

nice catch! haven't seen those! great work @martin107

this is strange but doesn't really matter but those changes that are made in latest patch is already done in #118. I was looking at that local branch wondering why my grep didn't return these and they were already changed to LanguageInterface..

oh well still a good catch

Status: Needs review » Needs work

The last submitted patch, 133: 2226533_133.patch, failed testing.

filijonka’s picture

@martin107 You need to do a diff without the M flag and mostly likely you need to reroll it to.

filijonka’s picture

129: 2226533_129.patch queued for re-testing.

filijonka’s picture

ok asking for a retest on #129 simply because when I applied that patch the changes that are in #133 interdiff are already there + when doing the tests locally they don't give the same results as in #129. So wanna see the result one more time

The last submitted patch, 129: 2226533_129.patch, failed testing.

martin107’s picture

@filijonka so I understand from IRC that some of the tests pass locally for you

Could you post your PHP version ...

I am storing a link to the relevant test results here as the current links maybe overwritten by future retesting
https://qa.drupal.org/pifr/test/792483

testbot was php5.4

filijonka’s picture

Status: Needs work » Needs review
FileSize
1.8 KB
515.55 KB

let's see what happends on testbot. I'm running on php 5.4.x as bot is.

the test parameter I changed is simply because locally the verbose message showed that there were more than 1 user on the system and since I used both cleaning the caches with drush and removed temporary tests we now it can exist more than 1 user. I'm just making sure to take a high number here and locally it got green then.

edit: adding that I don't think that is the solution I would just like to confirm if that is the case.

Since I don't know how this works on drupal but my thought is that if we really want to make sure that this test should pass we should choose a high number. In the back of my head it's simply like this: Can we now that all previous tests has cleaned up after itself so the setup for this test is the one adding a user?

Status: Needs review » Needs work

The last submitted patch, 141: 2226533_141.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
840 bytes
516.22 KB

hopefully this is down to one error.....

Status: Needs review » Needs work

The last submitted patch, 143: 2226533_143.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
516.26 KB

of course another reroll, auto-merged everything so no conflicts to handle
oh forgott to pull..coming new reroll soon

Status: Needs review » Needs work

The last submitted patch, 145: 2226533_145.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
515.4 KB

ok something must be very wrong with patch 145 so redid this based on patch 143

I've not seen this line @147 before in language.module but can't really find when it was introduced but I don't think it wasn't recently.

$language->is_new = $language_entity->isNew();

is_new is not a property of language as far as i can see but we should get fatals in that case..well let's see what the bot says

Status: Needs review » Needs work

The last submitted patch, 147: 2226533_147.patch, failed testing.

jiv_e’s picture

Assigned: Unassigned » jiv_e
Issue tags: +drupalcampfi
jiv_e’s picture

Assigned: jiv_e » Unassigned
Issue tags: -drupalcampfi

Sorry! I didn't have time to take this further in the sprint. An other issue came back to haunt me.

martin107’s picture

Status: Needs work » Needs review
FileSize
516.81 KB
733 bytes

Please ignore. #147 is the active patch.

Status: Needs review » Needs work

The last submitted patch, 151: 2226533_151.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
516.86 KB

Straight reroll of #147.

Status: Needs review » Needs work

The last submitted patch, 153: 2226533_153.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
501.19 KB

Reroll form #147 because my recent patches had more errors..

This is a PSR-4 reroll!

Status: Needs review » Needs work

The last submitted patch, 155: 2226533_155.patch, failed testing.

YesCT’s picture

Did you do it using the steps at:
https://groups.drupal.org/node/424758
?

martin107’s picture

@YesCT yes I did... although it looks like I messed something up .. locally I had test passing related to all conflicts I had to resolve!!!
Ii looks like HEAD moved on between submission and testbot testing.

Given :-

1) This issue has a history of frequent re rolling .. I notice several comments appealing for strategies on how to break this patch into parts..
I still have no useful insight into this question :-(

2) The commit spree juggernaut that is Austin is about to start.

I think this issue should be put aside for at least a week.

martin107’s picture

Assigned: Unassigned » martin107

I starting to reroll this now

martin107’s picture

Status: Needs work » Needs review
FileSize
308.59 KB

Now that #2246665: Typehint with Drupal\Core\Language\LanguageInterface instead Drupal\Core\Language\Language has been committed, lots of the changes that were made in both patches need to be unwound.
This patch is 40% smaller and should cause less conflicts in the future and so be easier to reroll.

I rerolled from #153 the last patch to at one time pass all tests.

This is not a happy reroll... When rebasing there were 120 conflicts to resolve! ( individual changes not files )

I am certain there will be some errors ... where there were non-trivial decisions to be made I tested the function until it passed

I am not expecting this to pass first time..

ALSO

Note in many files CoreLanguageInterface in this patch has become BaseLanguageInterface to reflect the current state of HEAD

Status: Needs review » Needs work

The last submitted patch, 160: 2226533_160.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
285.99 KB

some knots and kinks have been brushed out...

1) I fixed up these files in light of the PSR-4 changes.

core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php -- removed
core/modules/node/lib/Drupal/node/Controller/NodeController.php -- change ported to correct file and duplicate deleted.
core/modules/node/lib/Drupal/node/NodeStorage.php -- both changes already in core, duplicate deleted.

I made a patch at this point to see how much more of a reduction this would make ( the patch was 55% of the #153 )

2) I backout some ... ahem reroll confusion from the following files.
TranslationLinkTest.php
LanguageServiceProvider.php

3) Duplicate use statement reported in test failure was removed.(#160)

Running all the unit test did not expose any problems BUT my expectation is there are more problems lurking...

Status: Needs review » Needs work

The last submitted patch, 162: 2226533_162.patch, failed testing.

martin107’s picture

FileSize
24.66 KB

My apologies For the record here is the interdiff I omitted.

martin107’s picture

Status: Needs work » Needs review
FileSize
549 bytes
285.71 KB

Testing of the last patch ran only a little further and exposed another duplicate use statement issue similar to #162.3

I have listed all files changes in this patch 'git diff 8.x --name-only'
and through a little sed hackery I have run php -l on all relevant files...

So I don't think there are anymore linting issues like this for the test bot to find.

Does anyone know of a more convenient way of running the syntax checking part of testbot on my local machine ?

I was kind of expecting that running unit tests would identify these problems for me but hey-ho

So this time testbot should run deeper and expose more complex flaws..

Status: Needs review » Needs work

The last submitted patch, 165: 2226533_165.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
284.47 KB
1.24 KB

Small advance EntitySerializationTest.php now passes.

Status: Needs review » Needs work

The last submitted patch, 167: 2226533_167.patch, failed testing.

martin107’s picture

Assigned: martin107 » Unassigned

I won't be able to look at this for a few days ... I see echoes of past failures ... so does filijonka ..
when i return to this my next step is to look at a diff with #143 and look for correlations.

martin107’s picture

Status: Needs work » Needs review
FileSize
282.74 KB

This is just a straight reroll

Clearied 3 conflicts and in part, the patch became slightly simpler now that
#2281905: Stop caching plugin discovery/info hooks by language has been committed

So my expectation is a return to 11 fail(s), and 0 exception(s).

Status: Needs review » Needs work

The last submitted patch, 170: 2226533_170.patch, failed testing.

martin107’s picture

sorry cross post

martin107’s picture

Status: Needs work » Needs review
FileSize
282.87 KB

Reroll.

Core swapped check_plain() for String::checkPlain() in many places.

Status: Needs review » Needs work

The last submitted patch, 173: 2226533_173.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
283.35 KB
714 bytes

Big trouble, little fix.

Status: Needs review » Needs work

The last submitted patch, 175: 2226533_175.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
283.37 KB

Status: Needs review » Needs work

The last submitted patch, 177: 2226533_177.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
283.37 KB
681 bytes

cleared syntax error.

Status: Needs review » Needs work

The last submitted patch, 179: 2226533_179.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
282.64 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 181: 2226533_181.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
284.6 KB
2.27 KB

just keeping this patch upto date :-

CommentTypeTest and EntityFieldDefaultValueTest now back to green

Status: Needs review » Needs work

The last submitted patch, 183: 2226533_183.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
282.57 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 185: 2226533_185.patch, failed testing.

martin107’s picture

hmm not sure these changes can be justified.

index 1a028c9..39225ab 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -847,7 +847,7 @@ function l($text, $path, array $options = array()) {
   // Add a hreflang attribute if we know the language of this link's url and
   // hreflang has not already been set.
   if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) {
-    $variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId();
+    $variables['options']['attributes']['hreflang'] = $variables['options']['language']->id;
   }
 
   // Set the "active" class if the 'set_active_class' option is not empty.
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 101c5f3..d24aedc 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1212,7 +1212,7 @@ function template_preprocess_links(&$variables) {
           $link_element['#options']['set_active_class'] = TRUE;
 
           if (!empty($link['language'])) {
-            $li_attributes['hreflang'] = $link['language']->getId();
+            $li_attributes['hreflang'] = $link['language']->id;
           }
 
           // Add a "data-drupal-link-query" attribute to let the

martin107’s picture

Status: Needs work » Needs review
FileSize
1.81 KB
283.48 KB

The patch no longer applied .. so reroll ... made following change to keep things upto date

--- a/core/modules/field/src/Plugin/views/field/Field.php
+++ b/core/modules/field/src/Plugin/views/field/Field.php
@@ -904,7 +904,7 @@ function field_langcode(EntityInterface $entity) {
       $default_langcode = language_default()->getId();
       $langcode = str_replace(
         array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
-        array($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id, $default_langcode),
+        array($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), $default_langcode),
         $this->view->display_handler->options['field_langcode']
       );

Next
I have found one bug in content_translation.module

./core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php now passes.

PS regarding my comments in #187 yes they can all be justified...

Status: Needs review » Needs work

The last submitted patch, 188: 2226533_188.patch, failed testing.

martin107’s picture

regarding the lint failure from #188

for a full explanation see

http://stackoverflow.com/questions/1075534/cant-use-method-return-value-...

It's a limitation of empty() in PHP versions below 5.5.

I was using php5.5.10 locally and so that is why everything looks ok for me.

I will post a patch in the morning

martin107’s picture

Status: Needs work » Needs review
FileSize
1.02 KB
283.48 KB

quoting from http://kunststube.net/isset/

if (!myFunction()) -> concise equivalent of empty($var)

so replacing

empty($entity->getUntranslated()->language()->isLocked())

with

!$entity->getUntranslated()->language()->isLocked()

is directly equivalent .. these things can be tricky

martin107’s picture

FileSize
283.48 KB

Reuploading patch, in an effort to get testbot to act.

Status: Needs review » Needs work

The last submitted patch, 192: 2226533_191.patch, failed testing.

The last submitted patch, 191: 2226533_191.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
283.48 KB
616 bytes

#185-#192 needs a summary.

Despite starting with 6 failures and ending with 10 that was actually a minor positive step forward..

Drupal\system\Tests\Entity\EntityQueryTest is an intermittently failing test which accounts for 5 extra fails when it appears.
In short one repeatedly appearing bug has been fixed...

Note the differences between php5.5 and php5.4 handling of empty do not explain EntityQueryTest's intermittent nature. In theory or in practice.
I have looked back through the logs and can see those tests both passing and failing on when testbot was on php5.4.

But indirectly the empty() issue led me to search and find the next bug.

For me locally this next fix changes EntityQueryTest tests from pass to fail.

Status: Needs review » Needs work

The last submitted patch, 195: 2226533_195.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
667 bytes
283.01 KB

I am reverting a buggy change from the patch...

From locale.module here is the interdiff -

-    if (!empty($language->locked) && ($langcode != 'en' || locale_translate_english())) {
+    if (!$language->locked && ($langcode != 'en' || locale_translate_english())) {
       $form['languages'][$langcode]['locale_statistics'] = array(

A) The wrong language is modified.
$language relates to \Drupal\language\Entity\Language and not Drupal\Core\Language\Language which is the subject of this patch.

B) the condition of the if statement is altered
!empty($language->locked ) is the INVERSE of
!$language->locked

This affects many tests and removing this flaw exposed other issues... it may not decrease the error count but I am using testbot to uncover all the bugs lurking behind this one!

Status: Needs review » Needs work

The last submitted patch, 197: 2226533_197.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
282.89 KB
803 bytes

Bingo!!! Drupal\config\Tests\ConfigLanguageOverrideTest is now passing locally.

Many of the failing tests used language_save(). I have removed an out of scope change/bug from the patch which was causing a logical flaw.

language_save() :-
1) Before saving the $language_entiy save the state from isNew()

2) Save updates to the $language_entity

3) Working version: was using state saved in step 1 to determine if overrides should be installed.. buggy patch calling isNew() AGAIN and getting the wrong result...

  }
  $language->is_new = $language_entity->isNew();   <-- step one save state 

  // Assign language properties to language entity.
  $language_entity->label = $language->getName();
  $language_entity->direction = $language->getDirection();
  $language_entity->locked = $language->isLocked();
  $language_entity->weight = $language->getWeight();
  $language_entity->setDefault($language->isDefault());
  $language_entity->save();            <-------------------step two save the entity
  $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId());
  if ($language->is_new) {          <---step three BINGO !!!!!! patch fixed 
    // Install any available language configuration overrides for the language.
    \Drupal::service('language.config_factory_override')->installLanguageOverrides($language->getId());
    watchdog('language', 'The %language (%langcode) language has been created.', $t_args);
  }

Status: Needs review » Needs work

The last submitted patch, 199: 2226533_199.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
310.27 KB

Reroll caused by #2291777: Random fail in LanguageFallbackTest being committed.

In rewriting a test alexpott removed the need for some of this patch's changes...

Status: Needs review » Needs work

The last submitted patch, 201: 2226533_201.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review

I can install current head, BUT when I apply the patch and then drush si ... it fails ( or install time blows up )

I am just triggering testbot to see if it can see any problems.

Current HEAD :-

Commit: 234ed4f894c3cd27f6bc7e2e26b58b3cc38d61be [234ed4f]
Issue #2226267 by yched: Improve default value handling of fields to be consistent (follow-up).
Date: 25 June 2014 13:38:29 BST

martin107’s picture

201: 2226533_201.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 201: 2226533_201.patch, failed testing.

YesCT’s picture

Issue tags: -Novice

not really novice given the size and some of the tricky confusions.

also, doesn't apply. I'm rerolling now.

YesCT’s picture

Status: Needs work » Needs review
FileSize
310.19 KB
5.19 KB

just a reroll.
nothing tricky.
can ignore the conflict diff. playing with what might actually make sense.

conflicted with
#2272467: Remove usages of watchdog() from procedural code
#2286681: Make public properties on ConfigEntityBase protected

Status: Needs review » Needs work

The last submitted patch, 207: 2226533_207.patch, failed testing.

YesCT’s picture

martin107’s picture

This need a reroll.. I will try and find time tomorrow to both reroll and implement this change.....

But tonight I have only time for a small review...

in more than a few posts

https://www.drupal.org/node/2254011#comment-8930337
https://www.drupal.org/node/2226533#comment-8903649
etc

The use of !empty($language->locked ) appears in several places dotted throughout the patch.

The empty() wrapper should be moved into the isLocked() function :-

A) This is a maintenance hazard as someone will have to identify and uniformly change all instances, should the policy change to say using isset() instead.

B) the subtle change in definition of empty() between php5.4 and php5.5 will be avoided.

martin107’s picture

Status: Needs work » Needs review
FileSize
310.21 KB

I have not been able to spend as much time on this as I would like recently but here is a reroll.

no conflicts just auto-merging etc

Status: Needs review » Needs work

The last submitted patch, 211: 2226533_211.patch, failed testing.

martin107’s picture

FileSize
310.44 KB
664 bytes

So there is some circumstantial indications that empty(Locked) maybe a factor in the long running bug hunt that is
https://www.drupal.org/node/2254011#comment-8930337 but those largely relate to \Drupal\language\Entity\Language objects
not Drupal\Core\Language\Language objects

That was only important here because in the past I/we have mistakenly altered the empty($language->locked) statements before backing out the changes.

I hope that is clear :-)

Now I am talking about a minor code polish to Drupal\Core\Language\Language objects and the way isLocked() is handled.

Looking through core there are plenty of status(), hasTranslation() isNew() type function that use !empty() to implicitly cast the return to a bool.
Understandably it is employed where there is a complex coming together of several factor where keys may or may not be present( in an array for example. )

BUT

locked is an uncomplicated CONSTANT defined during construct().
There are only 2, other places that I can see that use this, slightly paranoid practise, to protect a boolean with such a simple lifecycle.
[ ConfigEntityBase.php status() and isNew() ]

So do we really need the empty()?

Then I looked at our own house and see that technically yes even we screw it up!!!

isLocked is initialized to be a FALSE by

  /**
   * Locked indicates a language used by the system, not an actual language.
   *
   * Examples of locked languages are, LANGCODE_NOT_SPECIFIED, und, and
   * LANGCODE_NOT_APPLICABLE, zxx, which are usually shown in language selects
   * but hidden in places like the Language configuration and cannot be deleted.
   *
   * @var bool
   */
  protected $locked = FALSE;

So FALSE will be the default when no value is supplied to the construct()
but then upon construction we override with and integer!!!!

  /**
   * The values to use to instantiate the default language.
   *
   * @var array
   */
  public static $defaultValues = array(
    'id' => 'en',
    'name' => 'English',
    'direction' => self::DIRECTION_LTR,
    'weight' => 0,
    'locked' => 0,  <--- override bool with int
    'default' => TRUE,
  );

We could go for a if statement in the constructor to cast the value, whatever it is, to a bool, and this would protect against inputs like NULL
but that approach seems too complicated.

This solution is simple the interdiff small, normally I would accept that this change is clearly "out of scope", but I am looking ways to counter the charge that


This issue is the only one that routinely exposes the problem, and so our errors maybe, simply the result of our own mistakes, and not necessarily the subtle exposure of a recurring design instability.

So I want to contribute to settling that question, one way or the other, in part by demonstrating that we have taken sufficient care to sweep away all irrelevant complications, or clouding factors.

martin107’s picture

Status: Needs work » Needs review

triggering testbot

Status: Needs review » Needs work

The last submitted patch, 213: 2226533_213.patch, failed testing.

YesCT’s picture

what if we take out all ->locked changes and see if it passes?
If it does pass, we can open a separate issue to deal with ->locked, and move on from here.

martin107’s picture

Thanks that is clear way to separate out issues, in a way I had not thought of ... it will be a few days before I can get to it.

YesCT’s picture

+++ b/core/modules/language/language.module
@@ -96,7 +96,7 @@ function language_help($route_name, RouteMatchInterface $route_match) {
-  return !$language->locked && \Drupal::currentUser()->hasPermission('administer languages');
+  return !$language->isLlocked() && \Drupal::currentUser()->hasPermission('administer languages');

noticed this small typo.

YesCT’s picture

Status: Needs work » Needs review
FileSize
304.98 KB
12.1 KB

an experiment to see if taking out the locked changes gets this to pass. I double checked (and triple checked) to make sure I got them all... but might not have.

Status: Needs review » Needs work

The last submitted patch, 219: 2226533_219.patch, failed testing.

martin107’s picture

All credit goes to YesCT for so elegantly piercing my assertion..about isLocked

YesCT++

Oh oh regarding my misspelling of isLlocked my inner troll cannot help but suggest that I made the same spelling mistake systematically
when creating the wikipedia page for the seaside town of Llandudno ( http://en.wikipedia.org/wiki/Llandudno )

martin107’s picture

Status: Needs work » Needs review
FileSize
277.28 KB
27.7 KB

Removed changes to core/modules/block/src/Tests/coreDevs

looks like I let this slip in between #199-#201

YesCT’s picture

FileSize
282.74 KB
1.63 KB

what? it's green?
I'm playing in #2274167: [ignore] Patch testing issue with this.

this is 213 (with the isLocked), with the accidental devs file removed as in 222, but with two typo fixes. interdiff is just the typo fixes.

YesCT’s picture

+++ b/core/modules/language/language.module
@@ -599,7 +599,7 @@ function language_language_entity_insert(LanguageEntity $language) {
-  $domains[$language->id()] = '';
+  $domains[$language->id] = '';

@@ -609,12 +609,12 @@ function language_language_entity_insert(LanguageEntity $language) {
-  unset($prefixes[$language->id()]);
+  unset($prefixes[$language->id]);
...
-  unset($domains[$language->id()]);
+  unset($domains[$language->id]);

why these changes? I think those are config language and not the core language class.

Status: Needs review » Needs work

The last submitted patch, 223: 2226533.223.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
282.73 KB

reroll since #2293825: Various test classes do not have a "Test" suffix, was an auto 3-way merge. no conflicts.

another patch coming.

Status: Needs review » Needs work

The last submitted patch, 226: 2226533.226.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
281.41 KB
1.95 KB

1. #143 added a mode change to core/scripts/run-tests.sh

reversing that.

2.

+++ b/core/modules/language/language.module
@@ -96,7 +96,7 @@ function language_help($route_name, RouteMatchInterface $route_match) {
  *   Use \Drupal\language\LanguageAccessController.
  */
 function language_access_language_edit_or_delete($language) {
-  return !$language->isLocked() && \Drupal::currentUser()->hasPermission('administer languages');
+  return !$language->locked && \Drupal::currentUser()->hasPermission('administer languages');
 }

This $language is a language module configurable language (Entity/Language) not a core language. (it's also in a deprecated function)

reversing that.

3. also in language.module

 function language_delete($langcode) {
   $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
-  if (isset($languages[$langcode]) && !$languages[$langcode]->locked) {
+  if(isset($languages[$langcode]) && !$languages[$langcode]->isLocked()) {

just fixing this nit white space after the if.

4. in language.module in function language_language_entity_insert(LanguageEntity $language) {

   // Add language to the list of language domains.
   $domains = language_negotiation_url_domains();
-  $domains[$language->id()] = '';
+  $domains[$language->id] = '';
   language_negotiation_url_domains_save($domains);

this is a change to $language, where it is a configurable language (Entity/Language) and not the core Language class.

reversed this change.

4.b.
two changes similar in
function language_language_entity_delete(LanguageEntity $language) {

Status: Needs review » Needs work

The last submitted patch, 228: 2226533.227.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
281.42 KB

Hmm
Having paid close attention I see that the recent changes are good, but I am still looking for a way forward on this given how unrepeatable the patches in this issue are proving see #223 and #2274167: [ignore] Patch testing issue

I have a few tests in mind, before I take the labor intensive step of separating this patch in parts, but see that it needs a reroll first.

Looking at the file diff between last patch and this all changes are of the type :-

< - '#title' => $this->t($definition['label']) . ' (' . $language->name . ')',
---
> - '#title' => $this->t($definition->getLabel()) . ' (' . $language->name . ')',

that is this patch, like head is now using $definition->getLabel()

Status: Needs review » Needs work

The last submitted patch, 230: 2226533.230.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
404 bytes
281.31 KB

Ok, so I have found something, I don't have all the answers, just a good story to tell and a new approach which turns the problem on and off
in a repeatable way so that it can be studied. Something we have been sorely missing.

So peviously I have summaried of https://www.drupal.org/node/2254011#comment-8813981 as

We have a complex revisionable-cacheable-database-storage mechanism ....
WHERE in a "write-revise-read" test is the data being corrupted?

To feel my way forward I tried to construct sentences that are true :-

A) Part of the problem maybe the presence of magic getters and setters and how we may be exciting a new found bad path through the caching system.
B) Part of the problem maybe the we may have missed a conversion from say $language->id to $language->getId() and the code then finds the wrong id or a null value.

My thought was well given B, if we return all protected properties to public, the getters will still work, but now any uncorrected direct access, that this issue wants to remove will also flow through the code as before.

In order, here is a list of all properties that have become protected on Drupal\Core\Language\Language objects.
1) name
2) id
3) direction
4) weight
5) default
6) negotiationMethodId
7) locked.

Here is the command I am using to show the problem - locally the test takes 19 seconds to say pass/fail. For me unlike YesCT's work with testbot, repeating the test over and over always yields the same answer.

php core/scripts/run-tests.sh --php /Applications/MAMP/bin/php/php5.5.10/bin/php --color --url http://dev.drupal.co.uk --verbose --file ./core/modules/system/src/Tests/Entity/EntityQueryTest.php

BINGO

if 1, 2, 3, 4, 5, 6, 7, are made public then the failing test passes - so my theory has legs! One of those pesky properties has not been fully converted!!!!

I am telling this long winded story to spark ideas in others and explain what I think - I have not fully explored this

The next test surprisingly narrowed the field down.

With only 1(name) made public and all other returned to protected the failing test still pass !!!! So it looks like name is the problem child.

I am looking for testbot to confirm that $name is the key.

Status: Needs review » Needs work

The last submitted patch, 232: 2226533.232.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
721 bytes
281.76 KB

I have found one instance where direct access to name was still being attempted.

It looks like the name property is being renamed to carry some kind of translatable heading text a curious concept.
but any further comment on that seems out of scope

from core/includes/update.inc

   if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
     $default = isset($default) ? $default : \Drupal::languageManager()->getDefaultLanguage();
     // Rename the default language.
-    $default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name));
+    $default->setName(t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
     $filtered_languages['site_default'] = $default;
   }

Looking further up the code I can say in all events $default is assigned to be the return of \Drupal::languageManager()->getDefaultLanguage(); which is documented to be of type \Drupal\Core\Language\LanguageInterface, so thats why its fits.

martin107’s picture

FileSize
281.84 KB

17 commits later, well this patch needs a reroll.

No conflicts, just merging etc.

NB - this is a still a trial patch as $name is declared public.

Status: Needs review » Needs work

The last submitted patch, 235: 2226533.235.patch, failed testing.

martin107’s picture

Just placing a stake in the ground to define what repeatability will look like when we have it.

I hope I have been clear that there was always a difference between what I see locally and what testbot reports.

HEAD is constantly changing and locally things are no longer as I reported in #232, using :-

php core/scripts/run-tests.sh --php /Applications/MAMP/bin/php/php5.5.10/bin/php --color --url http://dev.drupal.co.uk --verbose --file ./core/modules/system/src/Tests/Entity/EntityQueryTest.php

and patch 2226533.235.patch
Out of 10 runs 8 fails, 2 passes
Out of 10 runs clearing the cache in between with "drush cr", 8 fails 2 passes.

Now it looks like my locally testing and testbot agree... that is Mostly broken with the occasional pass.

martin107’s picture

FileSize
281.45 KB

Reroll.

martin107’s picture

Status: Needs work » Needs review
YesCT’s picture

Status: Needs review » Needs work

The last submitted patch, 240: 2226533.240.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
280.58 KB

Not the cleanest of rerolls.

Recently many deprecated functions has been removed, some relating to the language class, so the patch size is reduced a little.
if the functionality has just been moved I may have missing something so I don't guarantee success.

Status: Needs review » Needs work

The last submitted patch, 242: 2226533.242.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
281.46 KB
1.09 KB

All but Drupal\contact\Tests\ContactStorageTest seem to have a simple error in common.

Now I have Drupal\contact\Tests\ContactSitewideTest passing, I have high hope for the rest...

BTW CrudHookTest which failed recently in #240, passed in #242 - so that was accidently fixed :)

Status: Needs review » Needs work

The last submitted patch, 244: 2226533.244.patch, failed testing.

martin107’s picture

A) The practise of daily rerolling this issue in not productive.

B) Myself and others don't consider stepping through the debugger on this issue a good way forward.

C) This issue converts several properties to protected. They can be split off into separate issues.

I think realistically the only way forward on this issue it to redefine it as a META.

Each separate issue will touch many parts of the system and so will need a "Will cause commit conflicts" tag

Any comments welcome, I will be on IRC for the next 8 hours or so

from 232

In order, here is a list of all properties that have become protected on Drupal\Core\Language\Language objects.
1) name
2) id
3) direction
4) weight
5) default
6) negotiationMethodId
7) locked.

martin107’s picture

After a brief chat in #drupal-i18n dropping the meta idea in favour of a series of child issues extracting what we can.

First up the hopefully uncontentious weight property

martin107’s picture

Status: Needs work » Needs review
FileSize
281.45 KB

Straight reroll.

Status: Needs review » Needs work

The last submitted patch, 248: 2226533.248.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
280.65 KB

@martin107 Thanks! To check the reroll I also rerolled 244.

conflicts from
#2287727: Rename FieldConfig to FieldStorageConfig
#1533250: Many coding standards clean-ups in locale module
#2146035: drupalSettings.path.pathPrefix does not contain the language identifier
#597236: Add entity caching to core

1. resolved conflict in FieldTranslationSqlStorageTest by taking out the use re-ordering, and leaving in the renaming of the other class. This is different than the reroll in 248.
2. a conflict from correcting stand of name languageName to language_name. This is different than the reroll in 248.
3. and one from a double space to a single space from that standards clean up also.

4. this was an interesting conflict in LanguageNegotiationUrl.php

<<<<<<< HEAD
      if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->id])) {
        $options['prefix'] = $config['prefixes'][$options['language']->id] . '/';
=======
      if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->getId()])) {
        return empty($path) ? $config['prefixes'][$options['language']->getId()] : $config['prefixes'][$options['language']->getId()] . '/' . $path;
>>>>>>> 244 on july15

as it seems like what was a return was just setting the first part. so I wonder if we needed to find the rest of the logic from the ternary.
from #2146035: drupalSettings.path.pathPrefix does not contain the language identifier
but

diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
index 1cb5ccd..f2c3330 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
@@ -141,7 +141,7 @@ public function processOutbound($path, &$options = array(), Request $request = N
     $config = $this->config->get('language.negotiation')->get('url');
     if ($config['source'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
       if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->id])) {
-        return empty($path) ? $config['prefixes'][$options['language']->id] : $config['prefixes'][$options['language']->id] . '/' . $path;
+        $options['prefix'] = $config['prefixes'][$options['language']->id] . '/';
       }
     }
     elseif ($config['source'] ==  LanguageNegotiationUrl::CONFIG_DOMAIN) {

Is the complete change... so I guess there nothing added later to the logic there that we need to adjust.

5. we didn't need the addition of the $entities typehint since 597236 added the @param docs for it.
this makes my reroll different than the one in #248

martin107’s picture

Status: Needs review » Needs work

The last submitted patch, 251: 2226533.251.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
279.64 KB
1.16 KB

Language::sort fixes.

Status: Needs review » Needs work

The last submitted patch, 253: 2226533.253.patch, failed testing.

martin107 queued 253: 2226533.253.patch for re-testing.

The last submitted patch, 253: 2226533.253.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
279.61 KB

I currently have no idea on how to proceed with the EntityTranslationTest failures, but in the mean time, the patch needs rerolling.

Trivial conflicts in toolbar.module were causing conflicts.

Status: Needs review » Needs work

The last submitted patch, 257: 2226533.257.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
616 bytes
280.21 KB

Single fix restores all tests but EntityTranslationTests.

Status: Needs review » Needs work

The last submitted patch, 259: 2226533.259.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
278.75 KB

1.
rerolling for
#2313627: FormStateInterface needs @ingroup
#2218313: Toolbar subtree is broken if you use a different language.
#2225353: Convert $form_state to an object and provide methods like setError()
#2149197: Replace format_interval with \Drupal::service('date')->formatInterval()

#2301319: MenuLinkNG part5: Remove dead code; and party! will do an interdiff to look for places in the menu stuff to that might need to use methods.

2.
2a.
Note this conflict is something I want to keep in mind

<<<<<<< HEAD
  public static function sort(&$languages) {
    uasort($languages, function ($a, $b) {
      return SortArray::sortByWeightAndTitleKey($a, $b, 'weight', 'name');
    });
=======
  public static function sort(LanguageInterface $a, LanguageInterface $b) {
    if ($a->getWeight() == $b->getWeight()) {
      return strnatcasecmp($a->getName(), $b->getName());
    }
    else {
      return $a->getWeight() < $b->getWeight() ? -1 : 1;
    }
>>>>>>> 250 on july23

and relates to #2239399: Languages should be sorted by label instead of title and #2304651: Core Language sort() should not work, needs to use name instead of default title

2b.
This patch was:

    * Sort language objects.
    *
-   * @param array $languages
-   *   The array of language objects keyed by langcode.
+   * This is a sort() callback.
+   *
+   * @param \Drupal\Core\Language\LanguageInterface $a
+   * @param \Drupal\Core\Language\LanguageInterface $b
+   *
+   * @return int
+   *   -1, 0, or 1.
    */
-  public static function sort(&$languages) {
-    uasort($languages, 'Drupal\Component\Utility\SortArray::sortByWeightAndTitleKey');
+  public static function sort(LanguageInterface $a, LanguageInterface $b) {
+    if ($a->getWeight() == $b->getWeight()) {
+      return strnatcasecmp($a->getName(), $b->getName());
+    }
+    else {
+      return $a->getWeight() < $b->getWeight() ? -1 : 1;
+    }

2c.
completely removing the only use of sortByWeightAndTitleKey().
and changing it to sort by weight and then then name.

we should not have to do any of this now that #2304651: Core Language sort() should not work, needs to use name instead of default title is in. so this reroll is undoing that since 2304651 got committed.

2d.
the missing return should be added by another issue, maybe something to go through that whole file and look for any @param or @return or typehints that are wrong/missing. (we might be able to also change that typehint for the @param on sort to be LanugageInterface[] instead of just array... anyway, out of scope for this issue.

2e.
check usages of sort() that this patch may have had to change that now also need to undo.

like

-      Language::sort($this->languages);
+      uasort($this->languages, '\Drupal\Core\Language\Language::sort');

in core/modules/language/src/ConfigurableLanguageManager.php
(note here we are again getting language module configurable languages confused with core language languages.

this looks like a bug in core. I checked the type of things that are in $this->languages
It comes from
class ConfigurableLanguageManager extends LanguageManager implements ConfigurableLanguageManagerInterface {
the core LanugageManager
still troubling. but putting back to just
Language::sort($this->languages);
also in core/includes/update.inc

-----
3.
3a.
phpunit on 261 says:
OK, but incomplete, skipped, or risky tests!
Tests: 5345, Assertions: 9527, Incomplete: 1.

3b.
but that is happening in head also, so not the fault of this issue.

3c.
ran with --tap and it said:
not ok 2250 - Drupal\migrate_drupal\Tests\source\d6\NodeRevisionTest::testRetrieval # TODO Incomplete Test

-----
4.
4a.
Looking into what might be different from my and the other recent rerolls.
so I also rerolled 259... :)

and the only diff between a rerolled 259 and my 261 was:

< diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
< index 8dbb4e2..cc0a49c 100644
< --- a/core/modules/menu_ui/menu_ui.module
< +++ b/core/modules/menu_ui/menu_ui.module
< @@ -215,7 +215,7 @@ function menu_ui_node_save(EntityInterface $node) {
<            'weight' => isset($definition['weight']) ? $definition['weight'] : 0,
<            'hidden' => 0,
<            'bundle' => 'menu_link_content',
< -          'langcode' => $node->getUntranslated()->language()->id,
< +          'langcode' => $node->getUntranslated()->language()->getId(),
<          ));
<        }
<        if (!$entity->save()) {

which is probably a good additional change and the result of menu link changes of various parts.

4b.
So did that also to my 261.

4c.
note that the typehint is wrong on
function menu_ui_node_save(EntityInterface $node) {
it actually has to be Node (NodeInterface is not enough)
(ContentEntityBase is what requires that getUntranslated() exists on the thing)
Maybe a separate follow-up issue needed here.
Not changing the type hint here.

4d
So I'm going to go through all the changes from the various parts of the menu link and look for code that have needed language changes.
But ... if we have any tests that execute code that uses a property, it would have caused test failures since the properties are protected in this issue.
(I'm on a plane and am now wishing I would have opened the test results in another tab, so I could see where the fails were.. have to do that when I land.)

in part4 there was this change

+          'langcode' => $node->getUntranslated()->language()->id,

which @martin107 caught. great.
I didn't see any others in part 1, 2, 3 or 5 (which only removed code)
-----
5.
5a.
checking any changes in core since 250 that may have added direct usages of properties that are now protected.
in #2216535: Replace Node overview topic and Node API topic with Entity Hooks topic
in core/modules/system/entity.api.php
it added this in comments:

+ * To make a render array for a loaded entity:
+ * @code
+ * // You can omit the language ID if the default language is being used.
+ * $build = $view_builder->view($entity, 'view_mode_name', $language->id);
+ * @endcode

5b.
I'm not sure of the type of that $language
Something similar is in core/modules/system/core.api.php
ah, taggled stuff that will get better when we force configurable languages to also extend the core language interface (and make the properties on configurable languages protected also.

5c.
Ignoring this for now. But maybe it needs a follow-up issue to look into it.
-----
6.
I didn't see any more changes in head.. so really need to look at those fails and submit this 261 to the bot (cause this sort() stuff could be causing it)
-----
7.
Completely unrelated, just making a note here. Will make a separate issue or ask on the formstateinterface one.
Look into this later.
Why was
/**
* {@inheritdoc}
*/
- public function getSourceLangcode(array $form_state) {
+ public function getSourceLangcode($form_state) {
return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->id : FALSE;
}
not hinting with the new FormStateInterface?

=========
in summary, the diff between 259 and 261 is how the sort() is handled.
let's see what the testbot says.

martin107’s picture

Regarding #261 7. form_state type hinting is resolved.. soon in #2313823: Use FormStateInterface for all typehints

martin107’s picture

Status: Needs work » Patch (to be ported)

Ughhh. Sorry it has taken a little while for the penny to drop...

Please forgive the long winded description I hope it will jar someone's brain into providing the answer.

A) Its seems we have traded the EntityQueryTest problems for EntityTranslationTest problems

Ignoring rerolls the only change was arround the function

\Drupal\Core\Language\Language

  /**
   * Sort language objects.
   *
   * @param array $languages
   *   The array of language objects keyed by langcode.
   */
  public static function sort(&$languages) {
    uasort($languages, function ($a, $b) {
      return SortArray::sortByWeightAndTitleKey($a, $b, 'weight', 'name');
    });
  }

B) When #2304403: Convert language:weight into a protected property was split off it involved changes to \Drupal\Core\Language\Language::sort() AND it also stalled on the same EntityTranslationTest problems ( see line 476 ).

So #2304403: Convert language:weight into a protected property is a subset of the changes in this issue..that contain the problem.
This issue should be postponed and the other reopened. We can then work on the common problem without
the daily rerolls that blights this issue, Also it should be easier to identify the problem needle in a smaller haystack!

martin107’s picture

Status: Patch (to be ported) » Postponed

postponed correctly

YesCT’s picture

Status: Postponed » Needs review
FileSize
278.77 KB

had to do this anyway while working on the random failure.
rerolled for
#1498660: Refactor taxonomy entity properties to multilingual
#2308821: Replace FormErrorInterface with $form_state->setErrorByName() and $form_state->setError()
#2313823: Use FormStateInterface for all typehints

I'm not sure if we should do the weight breakout of this... maybe we should postpone this on #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface?
But we might have to prove that 2246679 would help with the instability of translation related entity things.
Setting to review so the bot will run on the reroll.
Other versions are posted in #2315095: EntityTranslationTest webtest random failure in some patches (not HEAD)

YesCT’s picture

Assigned: Unassigned » YesCT

I'm going to make a new patch tomorrow. :) It will be good. :)

alexpott’s picture

Status: Needs work » Needs review
FileSize
987 bytes
279.15 KB

The language sort was failing because all the properties are protected thereby all the sorts returned 0 causing php to randomise the array order.

This means that SortArray::sortByWeightAndTitleKey() can be completely removed as this is the only use.

Posting patch since @YesCT and I worked on this together.

alexpott’s picture

Issue tags: +TCDrupal 2014
jmolivas’s picture

Assigned: YesCT » Unassigned
FileSize
280.61 KB
2.64 KB
214 bytes
143 bytes

I am the TCDrupal sprint working with @YesCT

We noticed @alexpott patch had unrelated change but the interdiff was fine so we apply the inteerdiff

Commented line was removed

Since the only usage of sortByWeightAndTitleKey function on core was removed, we remove the function and the test

------

We wrote a php class and test what was mentioned on #272

In order to run the code use:

$php MakeSureTest.php

This is the result

Array
(
    [somethingPublic] => I am a public string
    [*somethingProtected] => I am a protected string
)
I am a public string⏎

A review needs to be done to make sure the changes are within the scope of the issue. We thing this is really close to be ready but need a final review.

Chris Dart’s picture

FileSize
282.37 KB
2.2 KB

Removed remaining unused dataprovider public function providerTestSortByWeightAndTitleKey()

I am at the TCDrupal sprint with @YesCT

YesCT’s picture

I'm going to read through this whole thing, and remove unrelated changes.

YesCT’s picture

YesCT’s picture

I'm coming back to this and will be re-rolling it now (today).

YesCT’s picture

rerolled (thankfully the previous patch test results had the commit hash in the log)

#2326891: Convert system_element_info() to Element classes removed some code that had a ->id to ->getId change. that functionality was moved to \Drupal\Core\Render\Element\MachineName in #2305839: Convert hook_element_info() to annotated classes
#2037979: "Current user's language" views filter label is named very misleading removed some code, and also added new direct property usages.
#1966436: Default *content* entity languages are not set for entities created with the API added a direct ->id from a language
#1987882: Convert content_translation routes to a new style controller did some changes to use methods from properties. and moved some code around to ContentTranslationController that needed the changes done there.

there might be other new direct usages... but the testbot should catch them.
Let's see how this does.
(conflict interdiff can be ignored)

YesCT’s picture

Status: Needs work » Needs review
FileSize
273.96 KB
500 bytes

#2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface made ConfigurableLanguageInterface extend LanguageInterface
And this patch adds isLocked() to the languageInterface.
So, either ConfigurableLanguage needs isLocked() or isLocked() should be taken off the LanguageInterface (if it is only implementation for Language).
Since ConfigurableLanguage has a locked property, seems like it makes sense to add isLocked() to ConfigurableLanguage

We will probably have to do the same to ConfigurableLanguage as we are doing to this Language, it will need its properties protected and some clean-up.

#2188675: "Translate" local task always visible, leads to WSOD added some direct access to ->id ... I'll do that next. Here is just the isLocked() addition to ConfigurableLanguage.

YesCT’s picture

1.
this does the direct property accesses from #2188675: "Translate" local task always visible, leads to WSOD
(an interdiff for just that bit)

2.
and #2318817: remove method setId() from core/lib/Drupal/Core/Language/LanguageInterface removed setId from LanguageInterface
so this patch added some ->setId() in some tests...

like
PHP Fatal error: Call to undefined method Mock_Language_44567978::setId() in /var/lib/drupaltestbot/sites/default/files/checkout/core/tests/Drupal/Tests/Core/Utility/TokenTest.php on line 74

this patch tried to change

     $language = $this->getMock('\Drupal\Core\Language\Language');
     $language->id = $this->randomMachineName();

to

    $language = $this->getMock('\Drupal\Core\Language\Language');
    $language->setId($this->randomMachineName());

so.. send the id in as an arg to getMock...

public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false)

check the constructor for Language

which is

  public function __construct(array $values = array()) {

so...

becomes

    $values = array('id' => $this->randomMachineName());
    $language = $this->getMock('\Drupal\Core\Language\Language', NULL, array($values);

(but timplunkett in irc warned might need to getMock the interface, or getMockBuilder the class)

yeah, a more common pattern that I've seen before... so

    $values = array('id' => $this->randomMachineName());
    $language = $this->getMockBuilder('\Drupal\Core\Language\Language')
      ->setConstructorArgs(array($values))
      ->getMock();

3.
I'm not sure what to do with the fails like call to function on none object... will have to look at that still.

YesCT’s picture

oops. missed a setId() in FormatDateTest.

I'm taking another stab at this now.

YesCT’s picture

Status: Needs work » Needs review
FileSize
276.46 KB
YesCT’s picture

YesCT’s picture

Status: Needs work » Needs review
FileSize
15.15 KB
257.13 KB

taking out anything that could be considered out of scope

#2337825: Update comment references to the interface for ConfigurableLanguage class due to the ConfigurableLanguageInterface (followup)
#2337827: Language locked is a boolean, use TRUE FALSE not 0
#2337833: return should not have a variable name in LanguageMangagerInterface

not sure what to do with #2334763-9: Tidy up of LanguageInterface - removal of setters and other unnecessary methods so leaving that setDefault() in for now.
similar #2337835: set language->default in ConfigLanguageOverrideWebTest

#2337843: LanguageEditForm take out set name and direction, use create() parameters
#2337847: The negotiated method_id does not need to be sorted on the Language or ConfigurableLanguage object.
#2337853: set default better in LanguageConfigurationElementTest
#2337859: LanguageUrlRewritingTest should not be setting the id of a language
#2337867: set default better in MenuLanguageTest
#2337869: set language weight in EntityTranslationTest better using the constructor or something
#2337871: set language default in TwigTransTest better using the constructor or something

--
#2271363: Remove CacheDecorator and ProcessDecorator removed a file (CachedMockBlockManager) this one added back in, probably from a reroll... took back out.

--
there was a bunch of "use" noise. I dont think those are necessary. and #1989380: Remove unused "use" statements (eventually) will do that (or some similar issue) .. or we could have a separate issue related to Language to tidy that up. but we dont need to do that here.

Status: Needs review » Needs work

The last submitted patch, 291: 2226533.291.patch, failed testing.

YesCT’s picture

+++ b/core/modules/locale/locale.module
@@ -230,7 +230,7 @@ function locale_configurable_language_insert(ConfigurableLanguage $language) {
+  _locale_invalidate_js($language->id);

@@ -241,7 +241,7 @@ function locale_configurable_language_update(ConfigurableLanguage $language) {
-  _locale_invalidate_js($language->id());
+  _locale_invalidate_js($language->id);

what?! are these changes needed in this patch? and wouldn't it be ->getId() ... or are these not really language objects? (there are more similar things in locale.module)

YesCT’s picture

#2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods got in, so work to do here. (I also need to review the issues that go separated out.)

YesCT’s picture

linking #2340571: LanguageInterface needs isLocked method for the locked property. as related.

also, in irc @alexpott mentioned for this issue to really be complete, we should also protect the properties on ConfigurableLanguage.

I'm afraid of expanding the scope to that, but .. if that is what we should do, we will.

@alexpott also mentioned that this issue itself is not a beta deadline.

alexpott’s picture

Yep, this issue needs to protect the properties on the Language and ConfigurableLanguage then we can see that we've successfully converted core to use LangaugeInterface methods.

I don't consider this issue a beta-deadline or target since once #2339435: Default no longer needs to be a property on Language or ConfigurableLanguage, #2337847: The negotiated method_id does not need to be sorted on the Language or ConfigurableLanguage object., #2340571: LanguageInterface needs isLocked method for the locked property. and #2340609: use 'ltr' and 'rtl' for const values instead of 0, 1 so config more readable and diffable are done the interface is complete and correct and the objects don't contain anything unnecessary. Therefore, it is possible to use them completely correctly and have the properties change to protected and not break a contrib module.

It is an important issue for D8MI though since it'll enforce correct usage of the API.

martin107’s picture

The weight changes have been hived off it

#2304403: Convert language:weight into a protected property

and where it seemed natural to expand the scope and convert weight to a protected property...

Also, form a conversation in IRC

it would be nice to hive off all the

- $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id;
+ $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();

changes into a separate issue... to make the review process a breeze

Ok so I have created a new issue.

martin107’s picture

I am changing my approach ....

Yesterday I opened an issue to filter out all the get->id() changes from this issue..

because this issue is unworkable, "Will cause commit conflicts" should be read as needs daily reroll just to stay still..

As the getId() changes constitute the bulk of this issue, so #2340667: Protect Drupal\Core\Language\Language::id, and use getId() will need a daily reroll as well, aggh as I found out this morning :(

The solution is hive off the smaller part of this issue, not the big ones and resolve the getId() issue when the monster patch has been cut down in size.

So as weight and getId changes have been hived off so the getName() changes have been hived off .. #2341341: Change public 'name' property access on languages to getName() and add back setName()

martin107’s picture

Just making notes for myself in public

Now that all other split off issue are green...

There are more candidates for further dissection.

conversion of $this->locked into $this->isLocked()
conversion of direction from public to private
annotation improvements.

I am opening up a new issue to fix the annotations

mgifford’s picture

YesCT’s picture

in #2226533-300: Changes to the Language class due to the LanguageInterface (followup) @martin107 mentioned that direction could be split out. indeed it can. I was surprised I hadn't dont that already. Here it is: #2352029: Convert language:direction into a protected property

Note, some of our separate issues have been committed. yay!
#2340571: LanguageInterface needs isLocked method for the locked property.
#2304403: Convert language:weight into a protected property

YesCT’s picture

so, the list to focus on right now is:
#2341341: Change public 'name' property access on languages to getName() and add back setName() which looks like it has tricky errors.
#2352029: Convert language:direction into a protected property which has some fails but is small.
#2340667: Protect Drupal\Core\Language\Language::id, and use getId() which looks *really* close to being done, but is large.

YesCT’s picture

#2340667: Protect Drupal\Core\Language\Language::id, and use getId() is fixed.
and #2341341: Change public 'name' property access on languages to getName() and add back setName() has been green recently.

yay!

soo...
I guess it is time to see what changes here might be left.

I'll look now.

YesCT’s picture

it would be nice to get something committed here, so that people who worked on this over time (but not on other child issues) get recognized.

note #2336177: ConfigurableLanguage cannot be created/removed directly, integrate language_save() and language_delete() took care of some of the changes that were in this monster patch.

Only things I could find left were some typehints.

this patch is from scratch.
I read through the entire old one. no more to do here I think (from that old patch).
but we might want to think a bit on if there is something else to do here.

YesCT’s picture

FileSize
5.02 KB

reroll. automatic 3 way merge, no conflicts.

This needs a review! And I think we might be done here.

tstoeckler’s picture

Status: Needs review » Needs work
+++ b/core/includes/update.inc
@@ -11,6 +11,8 @@
+use Drupal\Core\Language\Language;
+use Drupal\Core\Language\LanguageInterface;

These don't seem to be used.

Otherwise looks perfect.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
4.77 KB

Let's see.

No interdiff, I just manually removed that hunk from the patch. (Yes... I'm that lazy!)

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome! Thanks @YesCT!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed cecf4ea on 8.0.x
    Issue #2226533 by martin107, filijonka, YesCT, Xano, jmolivas, Chris...
YesCT’s picture

Thanks everyone. This was pretty epic.

Status: Fixed » Closed (fixed)

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