As per #1216094: We call too many things 'language', clean that up we are converting schemas and parallel APIs to use 'langcode' instead of 'language' where a language code is involved. The use of 'language' inconsistently for language objects and language codes in Drupal 7 keeps throwing people off the cliff and makes understanding the API much harder. The attach patch is for comment module and is a possibly rough start. Let's see how it fairs with a complete test suite.

No upgrade path yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, comment-langcode-0.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
7.06 KB

Changes based on test failures. locale.test referred still to $comment->language in its tests and language form altering also used 'language' in place of 'langcode'. Let's see this one.

Gábor Hojtsy’s picture

Patch still needs update path and testing in the update, since it seems like it is certainly not tested given that it passes without the update path.

fastangel’s picture

FileSize
7.77 KB

Attached patch with update path. Lack testing the update.I'm still working on test it.

Status: Needs review » Needs work

The last submitted patch, comment-langcode-3.patch, failed testing.

fastangel’s picture

Status: Needs work » Needs review
FileSize
7.77 KB

Sorry

Status: Needs review » Needs work

The last submitted patch, comment-langcode-4.patch, failed testing.

fastangel’s picture

Work to pass the tests of update.

Gábor Hojtsy’s picture

Thanks for working on this! Regarding the added update code:

- we should drop the index first and then change the column name to be fully compatible with all databases supported; some databases don't like if you drop a column that takes part in an index :)
- I think this would be fine in a comment_update_8000() in comment.install, unless there is any special reason to do it in the bootstrap early; I don't think comments need to be loaded at that stage (unlike languages and path aliases), so we are fine running this update later as part of the standard update procedure; the bootstrap prepare updates are really special cases that we need to do early to even start up Drupal to update itself

fastangel’s picture

Status: Needs work » Needs review
FileSize
7.92 KB

New patch with comments of @gábor

fastangel’s picture

FileSize
7.68 KB

Sorry. I have included change en robots.txt :D

Gábor Hojtsy’s picture

Status: Needs review » Needs work

@fastangel: all right, the update function looks right. Update path testing is still missing unfortunately. Here are some tips to get going with that:

1. core/modules/simpletest/tests/upgrade/ has database dumps and test files to test the update
2. drupal-7.filled.database.php.gz is the dump for a filled Drupal 7 database to test with
3. If you ungzip the file, you'll notice it has PHP code to produce the Drupal 7 database setup, it has several nodes but it does not have comments
4. Edit the file and add a dump of a comment in the Drupal 7 database form (you can use core/scripts/dump-database-d7.sh to generate a dump of a comment table and copy-paste the relevant data into the dump)
5. Create a diff of the ungzipped original version and the new version (for posting your changes)
6. gzip the new version
7. Change the test in the upgrade_filled.test code to drupalGet() the node that you've attached the comment to, and check if the comment displayed. Also do a comment_load() on the comment to ensure that it loads and has the expected langcode value.
8. Enable the Testing module and run only the filled upgrade test (from under the Upgrade tests on Admin » Configuration » Testing), ensure it passes.
9. Do a git diff with git diff --binary so you get the diff of the gzip file as well to post.

This is about it to complete this patch. Can you try and look into making this addition? (Without update testing the patch is not committable because it does change the schema and ensuring it worked on an updated site would be important).

fastangel’s picture

Ok perfect. I'm working on it.

Gábor Hojtsy’s picture

Issue tags: +sprint

Tagging as current focus.

fastangel’s picture

FileSize
199.31 KB

Adapted patch to the latest version. Modified binary with comments. Missing perform the test.

fastangel’s picture

Status: Needs work » Needs review

Changed a needs review for testing. In my machine I always get error with path update :(

Status: Needs review » Needs work

The last submitted patch, comment-langcode-6.patch, failed testing.

fastangel’s picture

Status: Needs work » Needs review
FileSize
200.29 KB

Attached new patch with pass test.

Status: Needs review » Needs work

The last submitted patch, comment-langcode-7.patch, failed testing.

Gábor Hojtsy’s picture

+    $this->drupalGet('node/38#comment-1');

#comment-1 is not needed here, the URL path is absolutely enough.

+    $id_comment = $this->xpath('//div[@id=:comment_id]/', array(':comment_id' => 'comment-1'));

You can just put comment-1 right there in place of :comment_id.

+    $this->assertTrue(!empty($id_comment), t('Comment id 1 not found.'));

The t() in the assertTrue() should have a message that applies to the *success*. So it should say "Comment 1 found after update." or something like that.

+    $comment = comment_load(2);
+    $this->assertTrue($this->commentExists($comment->langcode), t('Comment id 2 found.'));

The t() is almost good here. Since we are checking for the langcode property specifically, we can say t('Comment 2 has a language code.')
I also don't see why you'd need $this->commentExists()? You can just do !empty($comment->langcode).

fastangel’s picture

Status: Needs work » Needs review
FileSize
200.39 KB

New patch attached

Status: Needs review » Needs work

The last submitted patch, comment-langcode-8.patch, failed testing.

fastangel’s picture

FileSize
200.39 KB

Sorry.

fastangel’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, comment-langcode-9.patch, failed testing.

fastangel’s picture

Status: Needs work » Needs review
FileSize
200.37 KB

Sorry. Today not is my day.

Status: Needs review » Needs work

The last submitted patch, comment-langcode-10.patch, failed testing.

Gábor Hojtsy’s picture

I ran the tests. They seem to result in

Fatal error: Class 'CommentStorageController' not found in {.....}/core/modules/entity/entity.module on line 298

Which seems to be a stock case of the class registry not being refreshed on the D8 update as far as I see or at least the test is not getting refreshed data when it attempts to run the comment API function. If you don't call the comment API directly from the test (ie. you only do the /node/28 drupalGet() test, NOT the comment_load() test), it is not an issue, so I suspect a local registry cache is the culprit.

So let's work with drupalGet() for now instead of trying to work around the particularities of the test system.

Then the second problem seems to be that node/38 does not exist. If you run the tests, i.e unable Testin module locally, go to Admin > Config > Testing an pick the Filled upgrade test from under the Upgrade tests, you get this at the end https://skitch.com/gabor.hojtsy/gh9t2/test-result-d8x.localhost. This basically says the node/38 is a 404. Looking at the DB dump, node 38 seems to be testing a node without a body field which is not in fact updated. That sounds reasonable IMHO. So let's pick a node that actually appears after the update and test with that!

Let me know if you need more help!

Gábor Hojtsy’s picture

@fastangel: do you intend to keep working on this or should I try and find someone else to help?

fastangel’s picture

Hi @Gábor,

I am working in this issue. This afternoon I will attach new patch. For now I don't need help.

Regards.

fastangel’s picture

@gábor Then For the first problem "cache in comment". I try get comment with other form?. For second problem. Do you prefer that I add body to node 38 or use other node?

Regards.

Gábor Hojtsy’s picture

@fastangel: 1. To directlyy get a comment, you can invoke its edit page too, at least to check it works. 2. Lets pick a different node that has a body (and does not have comments turned off). Thanks for your work!

fastangel’s picture

Status: Needs work » Needs review
FileSize
200.54 KB

I attach new patch.

Status: Needs review » Needs work

The last submitted patch, comment-langcode-11.patch, failed testing.

Gábor Hojtsy’s picture

@fastangel: I think we discussed above that comment_load() would hardly work in this update environment without a lot further tweaking. Can you please re-read my suggestions in #28? Also, it would be superb if you could write a few notes on what have you changed instead of just stating you upload a new patch. That you did upload a new patch we can see anyway from the attachment! More communication can help push issues along a great deal. Thanks!

fastangel’s picture

Ok. I have a one question. For second test (I will check the language of comment). I get the page for find the langcode?. About the last patch I attached:

  • Body to node 38 for test
  • Change get node 38 for get comment 1 y check if exists

Sorry for attached a lot of patch. You are right that is spreading much without comment.

Gábor Hojtsy’s picture

@fastangel: I think we also agreed above that you'd pick another existing node instead of changing the database dump for nodes. The nodes represented there are supposed to give a variety of update scenarios, and if you modify them at will, their test coverage will weaken. There must be a node among the 38 that can have comments and is published, right? Why mess around with what you have when you can pick a different one. I suggested this above in #28 and #32, now I'm suggesting it a third time.

On the comment_load() we figured out above that we are better off not trying to fix the whole testing environment but just read a different data source to verify it worked. I'd say the node test in the first place would pretty well ensure the langcode is there since the new code uses langcode all around and would spit out various notices if it would not work. If you want to be very specific to test if the right language code is used, you can write a direct DB query to avoid the update issues as well. That way the node test would test the whole cycle of attachment to nodes with language and then the db query would test for the langcode. Something like:

$comment = db_query('SELECT * FROM {comment} WHERE cid = :cid', array(':cid' => 2))->fetchObject();

(Instead of the comment_load()). And then check the langcode as with the existing assert() that is in your patch.

fastangel’s picture

@gábor: For one test. I thought use the exist node but all nodes en database have field comment is 0 (not active) Hence, I considered creating a new node. I change a node that has the active comments?. Or leave them closed and add the comment?.

Ok for second test I change the comment load for one query to database.

Sorry to make you lose so much time with these questions.

Gábor Hojtsy’s picture

@fastangel: if all nodes are marked to not allow comments, it sounds fine to add a whole new node to test this to make sure we are not stepping on other toes.

clemens.tolboom’s picture

I cannot apply the patch from #33.

Trying to follow the spirit of http://xjm.drupalgardens.com/blog/rerolling-drupal-8-core-patches I tried

git reset --hard
git checkout -b a7e6d4af1979b125d3da92395ae051a6b451d893
git apply ../comment-langcode-11.patch 
git st
git commit -am "Applied comment-langcode-11.patch"
git rebase 8.x

I guess the commit hash is the wrong one.

fastangel’s picture

I review the path and works with the latest checkout of 8.x. I am currently working on changes spoken with Gabor in the previous comments.

Gábor Hojtsy’s picture

I think this fails due to recent changes in the DB dump. I looked into how the DB dumps are managed in D7 and there seem to be great componentization there that we could leverage there, with the smaller dumps not even gz-ed, so we can patch them better. See http://drupalcode.org/project/drupal.git/tree/refs/heads/7.x:/modules/si...

To me it looks like we should migrate to that model sooner than later to avoid this continued need to reroll the update dumps (and post them as binary patches). We can either do it here or in #1357918: Missing update for language_default in language langcode update and then work with that setup for further language tests. Clemens, would you be interested to help out with that?

fastangel’s picture

Status: Needs work » Needs review
FileSize
208.73 KB

I attached new patch. The changes of patch:

  • change comment_load by db_query
  • Check comment with http response
  • Create node with $node->comment=2

Passing the test (upgrade) locally I have a problem: "The test did not complete due to a fatal error.". I think this has to do with what @gábor speaks at # 42. If you enlighten me a bit I think I can help.

Status: Needs review » Needs work

The last submitted patch, comment-langcode-12.patch, failed testing.

clemens.tolboom’s picture

@Gábor ... the componentization of db dumps still in gz format only helps a little.

I added a comment to #1182296: Add tests for 7.0->7.x upgrade path (random test failures) http://drupal.org/node/1182296#comment-5560684 as I don't understand the gz dumps for db files. There is probably a motivation for this so hope to hear more about that.

This http://drupalcode.org/project/drupal.git/commit/730f77f2f9ed5030f392d7d8... is the initial git addition of the test files.

Gábor Hojtsy’s picture

@clemens: the D7 dumps I linked mostly dont use gz and are easier to diff/patch.

clemens.tolboom’s picture

@Gábor regarding the 'Can you help with that?' question.

I have no clue yet how to do this. In #12 you put the steps about what to do. I'm happy to make a book page for that. Any clue where to put that page?

Checking http://drupal.org/simpletest the http://drupal.org/book/export/html/29571 to find out it does not contain the word 'upgrade' :(

clemens.tolboom’s picture

@Gábor: what link you are refering as http://drupalcode.org/project/drupal.git/tree/refs/heads/7.x:/modules/si... contains for D7 only gz files like drupal-7.bare.standard_all.database.php.gz ... or am I missing something.

Gábor Hojtsy’s picture

@clemens: well, there are various non-gz files there, like http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/modules/si.... If you look at how they are used (http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/modules/si...), you'll see they are loaded on top of the filled database and then used for testing. In effect, the filled database is a common default for all kinds of update test, where the actual sub-feature tests are componentized into their own add-on database dumps. I'm working on that to introduce in #1357918: Missing update for language_default in language langcode update hopefully later today. Stay tuned :)

clemens.tolboom’s picture

Lol ... so *.test are also db containers ... tnx

Regarding #47 : do you have a book page for this upgrade testing?

Gábor Hojtsy’s picture

Status: Needs work » Postponed

@clemens: I wrote this doc page based on your excellent questions: http://drupal.org/node/1429136. Also introduced easier to diff componentized language test files in #1357918: Missing update for language_default in language langcode update, so I think we should postpone this on that change. I hope it will be in quick, so we can move on with this.

Gábor Hojtsy’s picture

Issue tags: +language-content

Tagging for the content handling leg of D8MI.

Gábor Hojtsy’s picture

Status: Postponed » Needs work

Great, #1357918: Missing update for language_default in language langcode update landed, so now we can continue fixing the tests. @fastangel: can you continue work on this?

1. Good new is that you should not touch drupal-7.filled.database.php.gz anymore. Leave that alone.
2. All the db dumps you added to that gz before now should be added to the drupal-7.language.database.php file in the same directory. This is not gziped so we should be able to review your changes much easier, it should be easier to roll the patch itself and it will result in much smaller patches.
3. All other things we discussed above should still be fine.

Thanks for helping with this!

Gábor Hojtsy’s picture

Issue tags: +Needs tests

Needs tests as in test cleanups.

Gábor Hojtsy’s picture

Assigned: Unassigned » Gábor Hojtsy

Working on fixing that update test, since @fastangel apparently dropped the ball.

fastangel’s picture

Sorry. I've been very busy these days. If it's okay, I can get to work on it tomorrow.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
13.99 KB

With tests that actually pass. The test now uses the uncompressed dump, so we can have a full reviewable diff.

- added node 38 to the dump
- added comment 1 and comment 2 to the dump
- extended test to check for node 38 and both comments on the node page and checking the comment schema directly too

Passes upgrade tests on my machine. Please review!

Gábor Hojtsy’s picture

FileSize
13.99 KB

Minor code comment update.

Gábor Hojtsy’s picture

@fastangel: please use your available time to review the patch and if you think it properly tests the upgrade functionality! Let's move this forward finally!

fastangel’s picture

Hi,

To verify that there is the first comment. It would be best to check the route comment / 1?
for everything else it all works perfectly and I checked all cases.

Regards

Gábor Hojtsy’s picture

FileSize
13.96 KB

@fastangel: We use these to check for the unique comment titles. What would comment/1 give us on top of that?

+++ b/core/modules/simpletest/tests/upgrade/upgrade.language.testundefined
@@ -40,5 +40,15 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {
+    $this->assertText('First test comment', t('Comment 1 displayed after update.'));
+    $this->assertText('Reply to first test comment', t('Comment 2 displayed after update.'));

(Attached patch fixes only the missing newline at the end of the DB dump PHP file, no other change).

fastangel’s picture

I meant to know if accessing the url of the comment gives no problem. But of course if it is found in the node would not make much sense.

kalman.hosszu’s picture

@Gábor: I think the patch works well. If fastangel has the same opinion, the issue's status would change to RTBC.

Best

fastangel’s picture

Hi,

For me and would be correct. :D

Regards

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

RTBC based on both feedback comments above.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #61 does no longer seem to apply.

kalman.hosszu’s picture

Status: Needs work » Needs review
FileSize
14.05 KB

I resolved the conflict, the new patch attached.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Gábor Hojtsy’s picture

FileSize
14.05 KB

Fixed one minor typo. Interdiff would be:

-    // Directly check the comment language property on the first omment.
+    // Directly check the comment language property on the first comment.

Should not change RTBC status.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

Gábor Hojtsy’s picture

Issue tags: -Needs tests, -sprint

Change notice added at http://drupal.org/node/1450144, removing outdated tags.

andypost’s picture

under sqlite update does not works on one of testing sites...

The following updates returned messages
comment module
Update #8000

    Failed: PDOException: SQLSTATE[HY000]: General error: 1 table comment_2 has no column named language: CREATE INDEX main.comment_2_comment_nid_language ON comment_2 (nid, language); ; Array ( ) in db_change_field() (line 2990 of /var/www/core8/core/includes/database/database.inc).

will check latter, probably my testing site has some errors

Gábor Hojtsy’s picture

The D7 schema has the language column, so that error sounds like it is an issue in your system. Also the code does attempt to add a comment_nid_langcode index, not a comment_nid_language index.

andypost’s picture

steps to reproduce

git checkout 1878eb153470e2d8e32cabc09c717f6320d9dcb3
install core8
git checkout 5e6cc3c85a5f3b66ef202ed1aab99e3308daff5c
 run /core/update.php?op=info

this happens only on sqlite

The following updates returned messages
comment module
Update #8000

    Failed: PDOException: SQLSTATE[HY000]: General error: 1 table comment_0 has no column named language: CREATE INDEX main.comment_0_comment_nid_language ON comment_0 (nid, language); ; Array ( ) in db_change_field() (line 2990 of /var/www/core8/core/includes/database/database.inc).

git log core/modules/comment/comment.install

commit 5e6cc3c85a5f3b66ef202ed1aab99e3308daff5c
Author: Dries <dries@buytaert.net>
Date:   Tue Feb 21 10:55:52 2012 -0500

    - Patch #1410096 by fastangel, Gábor Hojtsy, kalman.hosszu: convert comment language code schema to langcode.

commit 1878eb153470e2d8e32cabc09c717f6320d9dcb3
Author: catch <catch@35733.no-reply.drupal.org>
Date:   Wed Jan 11 00:29:08 2012 +0900

    Issue #1357918 by Gábor Hojtsy: Change language schema to refer to langcode.

details

	Database system	SQLite
	Database system version	3.7.7.1
PHP	5.3.9-ZS5.6.0
andypost’s picture

Status: Fixed » Needs review
FileSize
526 bytes
+++ b/core/modules/comment/comment.install
@@ -259,3 +259,29 @@ function comment_schema() {
+  db_drop_index('comment', 'comment_nid_langcode');
...
+  db_add_index('comment', 'comment_nid_langcode', array('nid', 'langcode'));

we should drop comment_nid_language not comment_nid_langcode

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Right! So that is why it was looking for the old index. Duh. Trivial.

Gábor Hojtsy’s picture

Issue tags: +sprint

Tag again for sprint.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks!

Gábor Hojtsy’s picture

Issue tags: -sprint

Superb, thank you.

We are closing in on having everything standardized like this. Fields are being worked on at #1439692: Rename field language properties to langcode, help welcome there!

Status: Fixed » Closed (fixed)

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