Files: 
CommentFileSizeAuthor
#25 document-hook_search_info-conditions_callback-1948564-25.patch2.81 KBsarahdavies
PASSED: [[SimpleTest]]: [MySQL] 40,197 pass(es).
[ View ]
#22 document-hook_search_info-conditions_callback-1948564-22.patch2.81 KBbdgreen
PASSED: [[SimpleTest]]: [MySQL] 55,833 pass(es).
[ View ]
#20 document-hook_search_info-conditions_callback-1948564-20.patch2.82 KBbdgreen
PASSED: [[SimpleTest]]: [MySQL] 55,930 pass(es).
[ View ]
#15 document-hook_search_info-conditions_callback-1948564-15.patch3.6 KBbdgreen
PASSED: [[SimpleTest]]: [MySQL] 40,327 pass(es).
[ View ]
#12 1948564-document-hook_search_info-conditions_callback-11.patch2.62 KBaitiba
PASSED: [[SimpleTest]]: [MySQL] 55,844 pass(es).
[ View ]
#9 1948564-document-hook_search_info-conditions_callback-9.patch2.63 KBaitiba
PASSED: [[SimpleTest]]: [MySQL] 55,712 pass(es).
[ View ]
#6 1948564-document-hook_search_info-conditions_callback-6.patch2.72 KBaitiba
PASSED: [[SimpleTest]]: [MySQL] 55,537 pass(es).
[ View ]
#2 document-hook_search_info-conditions_callback-1948564-3.patch1.99 KBaitiba
PASSED: [[SimpleTest]]: [MySQL] 55,385 pass(es).
[ View ]

Comments

Issue tags:+Novice

To be more explicit: We recently adopted a new standard way to document "callback functions" -- see
http://drupal.org/coding-standards/docs#callback-def
for the standard and
#1250500: [policy adopted; patch done] Find a (standard) way to document callback signatures
for the issue where this was adopted.

In both Drupal 7 and 8, hook_search_info() uses a "conditions callback", and this issue is asking for this to be documented as a callback function... probably it should be called callback_search_conditions(), and its definition should be put into core/modules/search/search.api.php and referred to in hook_search_info(). In addition, we should check the core implementations of hook_search_info() to see if they are defining any conditions callback functions, and if so, make sure their documentation says "Implements callback_search_conditions()." as the first line (probably).

Might be a good Novice project?

Status:Active» Needs review
StatusFileSize
new1.99 KB
PASSED: [[SimpleTest]]: [MySQL] 55,385 pass(es).
[ View ]

This is my first patch to an issue, so I'm novice. This is what I do.

> Might be a good Novice project?

Are you sure? I didn't tag it as such because install profiles are a fairly hairy topic! But I see we have a novice taking a stab at it, so who am I to judge! :D

Oops. I am commenting on the wrong issue. Sorry!!!

Status:Needs review» Needs work

Excellent start!

A few things to fix:

a)

/**
- * Implements hook_search_info().
+ * Implements callback_search_conditions().
  */
function search_extra_type_search_info() {

I don't think this change is correct. Based on the function name, I think this is actually an implementation of hook_search_info() not a conditions callback. There is another function in there called search_extra_type_conditions() that is actually the conditions callback; that function doc should be changed to say "Implements callback_search_conditions()."

b) In the hook_search_info() documentation in search.api.php, I'd like to see the wording "... an implementation of callback_search_conditions()..." in the documentation, rather than "Sample callback function: callback_search_conditions()".

c) In search.api.php, I think we need to change the first line of the callback_search_conditions() function doc to conform to our standards for these callback functions. It should be something like "Provide search query conditions."

See http://drupal.org/coding-standards/docs#callback-def for standards for these changes.

Thanks!

Status:Needs work» Needs review
StatusFileSize
new2.72 KB
PASSED: [[SimpleTest]]: [MySQL] 55,537 pass(es).
[ View ]

Fixed (or try to do it!) :-)

+++ b/core/modules/search/search.api.php
@@ -46,22 +42,29 @@ function hook_search_info() {
+ * @param $keys
+ *   Name of a callback function that is invoked by

Does this callback get another callback as a parameter? O_o

Status:Needs review» Needs work

Thanks! The changes to hook_search_info() documentation look perfect. And the changes to the file search_extra_type.module look good, except that you have added an extra space to the end of one line, and there should not be a blank line at the end of the documentation block:

+ *
  */
function search_extra_type_conditions() {

The documentation for callback_search_conditions() needs some work though:
- The first line is good.
- The next line about hook_search_info() is good.
- After that, we should have this text that was previously in hook_search_info() (with a small change):

This callback is invoked by search_view() to get an array of additional search conditions to pass to search_data(). For example, a search module may get additional keywords, filters, or modifiers for the search from the query string.

- After that, we should have the text that was already in the sample callback (in a new paragraph):

*
* This example pulls additional search keywords out of the $_REQUEST variable,
* (i.e. from the query string of the request). The conditions may also be
* generated internally - for example based on a module's settings.

- Then we need @param $keys, and the text for that should be something like "The search keywords string."
- Then we need the @return. The text in the patch is good for that, except it should not say "Defaults to NULL" (that does not make sense in a return value).
- The documentation block must not have a blank line between it and the code:
  */
+
+function callback_search_conditions($keys) {

Status:Needs work» Needs review
StatusFileSize
new2.63 KB
PASSED: [[SimpleTest]]: [MySQL] 55,712 pass(es).
[ View ]

Thanks jhodgdon for the detailed comment! Very grateful for that.

A new patch with the commented things fixed.

Status:Needs review» Needs work

Great! You added one extra space at the end of the /** for function search_extra_type_conditions(), but other than that, the patch looks good to me!

We don't ever want extra spaces at ends of lines in Drupal code... If you plan to keep doing Drupal patches, try to set up your code editor to either remove spaces at the end of lines, or to show you spaces at the end of lines.

Some text editors have a command to strip all trailing whitespace (eg TextMate which I use does). It's a good habit to get into just hitting the shortcut for that at the same time as you save :)

Also, some git GUIs show trailing whitespace in the diff. I think git diff on the terminal does too.

Status:Needs work» Needs review
StatusFileSize
new2.62 KB
PASSED: [[SimpleTest]]: [MySQL] 55,844 pass(es).
[ View ]

Fix it!

As I have intention to continue making patches I set up my editor. On save a document, it remove the trailing white space/s

As help: To remove trailing white space on save on subline text 2, set to TRUE "trim_trailing_white_space_on_save" clicing on Preferences -> Settings - Default

Assigned:Unassigned» jhodgdon
Status:Needs review» Reviewed & tested by the community

Looks good! I'll get this committed soon, unless someone else beats me to it.

Version:8.x-dev» 7.x-dev
Assigned:jhodgdon» Unassigned
Status:Reviewed & tested by the community» Patch (to be ported)

Thanks again! Committed to 8.x

The patch does not apply to 7.x and needs to be ported.

Status:Patch (to be ported)» Needs review
StatusFileSize
new3.6 KB
PASSED: [[SimpleTest]]: [MySQL] 40,327 pass(es).
[ View ]

Backport to 7.x ... ;)

Assigned:Unassigned» jhodgdon
Status:Needs review» Reviewed & tested by the community

Looks good, thanks! I'll get it committed shortly.

Assigned:jhodgdon» Unassigned
Status:Reviewed & tested by the community» Fixed

Thanks again! Committed to 7.x.

I think the D8 patch may have been missing an ingroup/addtogroup: http://api.drupal.org/api/drupal/core!modules!search!search.api.php/func... -- this is showing in the 'hooks' group.

Version:7.x-dev» 8.x-dev
Status:Fixed» Needs work

Ah, yes. The callback_search_conditions() function in search.api.php should be taken out of the @addtogroup hooks {} section that is in search.api.php, and it should have @ingroup callbacks added to it. I missed that -- thanks for finding it joachim! Needs a quick follow-up patch for 8.x/7.x.

Status:Needs work» Needs review
StatusFileSize
new2.82 KB
PASSED: [[SimpleTest]]: [MySQL] 55,930 pass(es).
[ View ]

Hmm :-( Revision due to #19 ...

Status:Needs review» Needs work

Thanks! That's just about right; two little things to fix:
- I think we still want it to have @ingroup search as well as @ingroup callbacks.
- No newline at end of file

Status:Needs work» Needs review
StatusFileSize
new2.81 KB
PASSED: [[SimpleTest]]: [MySQL] 55,833 pass(es).
[ View ]

@jhodgdon returned @ingroup search and added newline :$ - thanks!

Assigned:Unassigned» jhodgdon

Looks good, thanks! I'll get it committed shortly.

Version:8.x-dev» 7.x-dev
Assigned:jhodgdon» Unassigned
Status:Needs review» Patch (to be ported)

Thanks again! Committed to 8.x. Needs backport to 7.x.

Status:Patch (to be ported)» Needs review
StatusFileSize
new2.81 KB
PASSED: [[SimpleTest]]: [MySQL] 40,197 pass(es).
[ View ]

Trying a backport for the first time.

Status:Needs review» Fixed

The file is missing a newline at the end... but other than that the patch is good. To save time, I just added the newline and committed the patch. Thanks!

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