Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To reproduce, go to admin/build/block and enable a block. Type in a journal entry and hit Save Blocks. Go to admin/reports/journal and notice that the journal entry does not appear.
I don't see anything in the watchdog log, and no messages were displayed.
Other modules installed: cck, demo, og, og_reg_keys, views - but I'm pretty sure this is happening regardless of any other contrib modules.
Comment | File | Size | Author |
---|---|---|---|
#32 | journal_474422.patch | 4.43 KB | evoltech |
#31 | journal_474422.patch | 4.44 KB | evoltech |
#27 | journal_474422.patch | 4.31 KB | evoltech |
#25 | journal_474422.patch | 4.36 KB | evoltech |
#23 | journal_474422.patch | 4.1 KB | evoltech |
Comments
Comment #1
bonobo CreditAttribution: bonobo commentedPossibly, this is related to #479358: Journal entry does not save at admin/content/node-type/[content-type-name]/display
Comment #2
bonobo CreditAttribution: bonobo commentedReassigning back to the proper queue -- see http://drupal.org/node/26160/revisions (latest revision) for more on this.
Comment #4
marcp CreditAttribution: marcp commentedThis can be reproduced on a clean 6.12 installation with just the Journal module installed.
Comment #5
sunoh. Wild guess:
This means that all form element keys are hierarchical. Journal expects its values without #tree. Most probably, this can be solved by manually forcing #parents for Journal's form additions - or setting #tree to FALSE for Journal's parent element keys (not sure).
Comment #6
restyler CreditAttribution: restyler commentedHere is the fix that helped me:
(just add '#tree' => FALSE to the code in line 123-124)
Comment #7
sunThat, as a proper patch, is almost RTBC. :)
Comment #8
evoltech CreditAttribution: evoltech commentedThis patch includes the fix from sun and restyler above. It also includes the begining of journal.test which tests this bug as well as the basic functionality of the module. This patch was created against 6.x-1.x-dev and can be applied with "cd journal; patch -p0 474422.patch;"
Comment #9
evoltech CreditAttribution: evoltech commentedActually please use this patch as it includes a fixed copy of the journal.test file that also has a test for issue 479358. It can be applied as above: "cd journal; patch -p0 474422_479358.patch"
Comment #10
sunThanks! Looks promising from a quick peek.
See http://drupal.org/node/156119 about issue statuses.
Since it seems that you fine folks want to provide some other patches, too - two ways to go from here:
a) I'll review this patch in detail and you fix the coding-style according to Drupal core's coding-standards. (Though I should note that I'm one of Drupal's chief-nitpickers.)
b) I'll fix a) myself before committing. Though that will most probably mean that this patch will languish a bit here until I can spare some time.
Comment #11
evoltech CreditAttribution: evoltech commentedI am not sure if you were insinuating that I needed to run a check on the code by the Drupal coding standards, so I did just in case. Here is a patch fixing the feedback I got from the coder module (including some misc fixes to .module and .install). It can be applied as above with (cd journal; patch -p 0 < 474422_479358_coder.patch). It should be noted that coder complains about camel cased functions in the test module, but this seems to be the standard across all other test files. A number of the parent methods of the test module in simpletest are in fact camel cased.
If this fact goes against your ideas of right and wrong coding practices, be sure to let me know and I will be happy to name them as you specify.
Comment #12
sunHoly cow! Awesome.
Yes, Journal module has come a long way, and certainly, I didn't adhere to Drupal's coding standards when I started to code for Drupal. :)
So here is the review:
Please replace that comment, using proper syntax for inline comments, always explaining why something is done, for example:
...
Missing space.
PHPDoc comments never start in the first line. Also a typo in that comment ("remoced").
Please remove those "chapter" comments.
getInfo() is the only exception we do not document. So just remove that PHPDoc, please.
We do not document SimpleTest basics, because documentation exists elsewhere. All of these comments need to be removed. Also note that those comments do not wrap at 80 chars.
Array keys are superfluous here.
Proper PHPDoc syntax for todos is
@todo
, followed by a space and the note. If the note is longer than 80 chars, following lines should use an extra indentation of 2 spaces.That said, this method does nothing, so we remove it. If the block is needed for another test, we implement a new testcase.
Doubled new line here. One is sufficient. Regarding that "chapter" comment, see above.
PHPDoc summaries should use the first form (not the third, i.e. without trailing "s"). All comments should form proper sentences, i.e. using a trailing period (full-stop).
Wrong syntax for inline comments. We use
// This is a comment.
$blocks is not defined; this leads to a PHP notice, because the value is assigned to a new array item without using a key.
We want to add some comments about what is done here. Also, it looks like some debugging code was left over.
If you (basically) negate the summary, so it summarizes the test, then the summary would work. We do not refer to bugs in PHPDoc. Note that PHPDoc summaries (the first line) never wraps (only the description should wrap at 80 chars). That additional PHPDoc description should be injected using inline comments into appropriate places in the test. So the remaining PHPDoc will (basically) be:
...
Both tests test the same (see above, revised PHPDoc summary), so we only need one. We want to keep the one for blocks, because Block module is not an optional contrib module.
The test method needs a proper name - based on above PHPDoc, I'd recommend 'testFormTreeEnabled'.
drupalPost should directly follow the $edit array, so the dependent code is also visually connected.
Comment #13
evoltech CreditAttribution: evoltech commentedPlease see attached the new patch with your recommendations.
Were your recomendations made from manually reviewing the code, or is there some additional tool I should be using for checking my code against drupal coding standards?
=== PATCH redacted (see below) ===
Comment #14
evoltech CreditAttribution: evoltech commentedwhoah ... not sure exactly what happened there. I don't think I should be submitting patches after workign outside all day, the previous one is not complete. Please use the one below.
Comment #15
sunNow I have to wonder: Contrary to what comment #6 in this issue is saying, you are applying #tree to all sub-elements instead of the parent 'journal' element - why is that?
In this context, "journal" should be written as proper noun, i.e. properly capitalized.
I don't think that Content and Text modules are required for the test any longer.
Can we write that permissions array onto one line, please? The other $edit arrays can be left multi-line.
Not using first form ("Test" instead of "Tests") and missing punctuation, i.e. trailing period (full-stop). This applies to all PHPDoc summaries in the patch.
Inline comments should use a leading space, i.e.
// Add...
instead of//Add...
, form a proper sentence (first letter uppercase), and use proper punctuation (trailing period).Rename to testJournalAddEntry() ?
It looks like these assertions are the same as in testJournalAddJournal(), except the last assertText(). If so, we should strip this block and move the last assertion into testJournalAddJournal(), i.e. testJournalAddEntry().
Could you explain why you did not use
$this->drupalGet('admin/reports/journal');
? I am pretty sure that there is no reason, so we should use the standard way.Please no leading or trailing blank lines in the body of classes and functions.
Comment #16
evoltech CreditAttribution: evoltech commentedI am applying "'#tree' => FALSE,' to both journal_entry and journal_location because they are both affected by the same bug. I discovered this when adding in the logic for Allow single tags for Journal entries today.
Regarding testJournalAddEntry() vs. testJournalFormTreeEnabled() having similar functionality, it is a good point, but they are two logically different tests. From the perspective of test based coding there should be a test that exercises the basic functionality of a module (testJournalAddEntry()) and one for each bug that is found for regression testing (testJournalFormTreeEnabled()). While this increases the amount of code that exisits in the journal.test file I think it serves as good documentation. But then again since this is the first revision of journal.test, maybe this logic should go into the testJournalAddEntry() function. This is what I ended up doing. What are your thoughts on this?
Please see the attached patch.
Comment #17
sunI highly believe that restyler's solution in comment #6 should work equally, because #tree is applied recursively by Form API. That means, we do not have to apply #tree to each and every element below
$form['journal']
, but exactly that parent element only instead....should form a proper sentence - ideally rephrase into "Installation functions for Journal module."
Same here, but also missing blank line between @file PHPDoc block and class. There should only be no blank line if the PHPDoc belongs to the class/function (which also means that the PHPDoc for this test case class is missing ;) ).
If you split the test here, re-introducing the former testJournalFormTreeEnabled(), then we have two atomic tests - one "simple" that ensures basic functionality. And a first "special" test that ensures functionality under a certain condition (#tree).
Still using a special way for getting 'admin/reports/journal' without explanation and most probably without reason. (two times)
Comment #18
marcp CreditAttribution: marcp commentedSounds like moving the
'#tree' => FALSE
up to$form['journal']
would be the best fix here as long as it works. It's less code and it will help future-proof the module by making sure any new form items that are added to the journal fieldset are configured properly.One other minor nitpick in the patch would be to enclose absolute in single-quotes instead of double the two times it appears in
testJournalAddEntry()
.Comment #19
sunNote that marcp's second nitpick is basically correct (-- Always use single quotes whenever double quotes are not technically required). However, we want to complete remove that
url()
invocation in$this->drupalGet()
, because it is superfluous -- at least I see no reason why it should be required.Comment #20
evoltech CreditAttribution: evoltech commentedplease see attached with the changes you recommended
Comment #21
marcp CreditAttribution: marcp commentedLooks cleaner. I haven't tried to apply the patch, though. Still looks like maybe sun wants an extra blank line between the @file PHPDoc line and the following line, which would be better as a complete sentence ("Installation functions for Journal module.").
Comment #22
bonobo CreditAttribution: bonobo commentedRE the comment in #17 and #21 about using a "complete sentence": the line
is not a complete sentence, as there is nary a verb to be found.
I'm assuming that we want the following rules in place:
1. Start comments with a capital letter;
2. End comments with a period (as suggested by sun in #12); and
3. Capitalize the module name when it is referred to as a proper noun (ie, "the Journal module" as opposed to "save a journal entry".)
Does that capture what we're shooting for?
Comment #23
evoltech CreditAttribution: evoltech commentedPlease see attached patch as per #21
Also the line after @file is where the summary goes, following this another newline delimits an optional description.
PS. you two should really submit to the coder module, so that these checks could be done automatically by me and other contributers who had to take an extra semester of English in college.
Comment #24
sunheh. I'm not good at English either. But I wrote the coder_format script that ships with Coder module. ;)
This looks much, much better now!
Only remaining issues I quickly note only, since already explained in detail above:
1) Missing blank line between @file and class in journal.test. (Optionally add PHPDoc for the class, though I'm not eager on that).
2) Split testJournalAddEntry() into two tests, existing test for admin/build/block/add, separated one for admin/build/block.
3) Remove url() from $this->drupalGet().
Comment #25
evoltech CreditAttribution: evoltech commentedSun,
testJournalAddEntry() is the combination of two separate functions that you had earlier suggested be one function. In a previous function, the first check test a basic journal entry that did not touch the '#tree' => FALSE bug, the second function _did_ touch the '#tree' => FALSE bug. At your suggestion I joined them.
I have address issue #1 and #3, please see patch below.
Comment #26
jgraham CreditAttribution: jgraham commentedSplitting testJournalAddEntry() in two tests;
#24
vs.
#17
I'm assuming that both posts are describing the same situation? If so I think it was a little unclear in #17 what that discussion was pertaining to since in #15 you had asked evoltech to combine into one function. If I understood the discussion properly, you are asking for testJournalAddEntry() to be split as described in #17.
If I'm mistaken please clarify.
Comment #27
evoltech CreditAttribution: evoltech commentedfixes the drupalGet() (in journal.test) issue mentioned above.
Comment #28
marcp CreditAttribution: marcp commentedI just tested out the patch and my journal entries are saving at admin/build/block -- yippee!
@sun - would it be possible to get this committed since it fixes a bug, and then open up any new issues for the simpletest stuff?
Comment #29
sunThanks! We are close to completion. :)
The confusion probably arose, because not all of my found issues were incorporated in the very next patch after each review. To clarify:
In #12 you had 3 tests:
- testJournalAddJournal()
- testJournal479358()
- testJournal474422()
and I asked to combine the second with the third.
After you did so, in #15 I then realized that
- the first part of the combined testJournalFormTreeEnabled() is the same as in testJournalAddJournal(), only with 1 additional assertion
and I asked to move that additional assertion into testJournalAddJournal() and remove the first part from testJournalFormTreeEnabled().
In #17, all tests were suddenly merged into one. ;)
#24 only repeated a few issues from #17 that were not yet incorporated.
Final issues:
- We sill want to have two atomic tests, testJournalAddEntry() for admin/build/block/add, and testJournalFormTreeEnabled() for admin/build/block (the #tree = TRUE test).
- Note that test methods use camelCase names like "testJournalAddEntry()", not "test_journal_add_entry()".
The new white-space fix here is good, but the change in string concatenation is not (please revert).
Comment #30
marcp CreditAttribution: marcp commentedSo, to paraphrase:
1. Split test_journal_add_entry() into 2 functions named testJournalAddEntry() and testJournalFormTreeEnabled()
2. Change:
to:
That's it! Almost done. Nice. Then we can move on to bigger and better things!
Comment #31
evoltech CreditAttribution: evoltech commentedfixed
$output = '\t' . "\n";
issuefixed
issue
Please see attached patch
Comment #32
evoltech CreditAttribution: evoltech commentedfixed
Comment #33
marcp CreditAttribution: marcp commentedThe patch still applies after yesterday's commit.
Comment #34
marcp CreditAttribution: marcp commentedRan the simpletests and, with the patch, they all succeed. Commenting out the 1-line real fix of the issue ('#tree' => FALSE) causes some failures.
Is this ready to be committed?
Comment #35
sunTests always go into a sub-directory "tests".
Did the back-port to D5 myself. ;)
Thanks for reporting, reviewing, and testing! Committed to all branches.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #36
sunoh, and please do a diff between your version and the new committed code - I did some further optimizations here & there.