Convert SQL queries & rewrite stormperson_validate() - seems the function is not doing what it should entirely.

Files: 
CommentFileSizeAuthor
#19 storm-1799550-sqlapi-d7-18.patch5.38 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#18 storm-1799550-sqlapi-d7-18.patch5.38 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#16 storm-1799550-sqlapi-d7-15.patch11.08 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#13 storm-1799550-sqlapi-d7.patch5.38 KBwillwh
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/storm/stormorganization/stormorganization.admin.inc.
[ View ]
#11 storm-1799550-sqlapi-d7-11.patch5.32 KBjuliangb
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#9 storm-1799550-sqlapi-d7-9.patch5.33 KBwillwh
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/storm/stormorganization/stormorganization.admin.inc.
[ View ]
#7 1799550-stormperson_user_autocomplete-7.patch924 byteswillwh
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1799550-stormperson_user_autocomplete-7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#6 1799550-more_sql_portage-6.patch12.58 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#4 179550-stormperson_user_autocomplete-4.patch2.26 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]
#3 179550-stormperson_user_autocomplete.patch2.21 KBwillwh
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

Comments

Can you elaborate your point about stormperson_validate()?

Hi julian, my bad, switching between my few local branches, I dropped a few lines in there (not what was in 7.x-1.x-dev) - so you can safely ignore the comment about stormperson_validate()

I am re-writing SQL to d7 api, in bits - haven't had a lot of time up until now, but I will provide patches asap :)

Title:Convert SQL queries & rewrite stormperson_validate()Convert SQL queries
Status:Active» Needs review
StatusFileSize
new2.21 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

Updating the issue title to better reflect the issue.

Fixed up the stormperson_user_autocomplete() syntax.

StatusFileSize
new2.26 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

Adding missing query limit, using ->range();

Status:Needs review» Needs work

+      ->condition('name', '%' . db_like($string) . '%', 'LIKE')

Looks here like we're changing from string% to %string%

+

One bit of trailing whitespace that's been added.

Status:Needs work» Needs review
StatusFileSize
new12.58 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

This patch is a little better.

I am a little stuck here though - _stormperson_user_load()

This always seem to be returning $account->uid = 0; - as the user_uid is always 0 on stormperson_insert($node)

I am not quite sure how to go about debugging this, any pointers appreciated :)

StatusFileSize
new924 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1799550-stormperson_user_autocomplete-7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Trying to post a patch that actually has correctly line endings etc.

Status:Needs review» Needs work

The last submitted patch, 1799550-stormperson_user_autocomplete-7.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new5.33 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/storm/stormorganization/stormorganization.admin.inc.
[ View ]

Here's a patch for the ajax load of users by name & validation query.

Still lots of work to be done on Storm Person :)

Status:Needs review» Needs work

The last submitted patch, storm-1799550-sqlapi-d7-9.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new5.32 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

I think there was a rogue bracket in #9. This should fix.

Status:Needs review» Needs work

A few questions on this patch:

+++ b/stormorganization/stormorganization.admin.inc
@@ -258,15 +258,19 @@ function stormorganization_list_filter_reset($form, &$form_state) {
+    $return = $query
+      ->addTag('node_access')
+      ->fields('n', array('nid', 'title'))
+      ->condition('n.type', 'stormorganization')
+      ->condition('title', '%' . db_like($string) . '%', 'LIKE')
+      ->range(0, 10);
+
+    foreach($return as $row) {
+      $matches[$row->title] = check_plain($row->title);

Need to execute() query.

+++ b/stormperson/stormperson.admin.inc
@@ -190,17 +190,20 @@ function _stormperson_organization_people_js($organization_nid=0) {
-    $s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormperson} AS spe ON n.vid=spe.vid WHERE n.status=1 AND n.type='stormperson' AND spe.organization_nid=%d ORDER BY n.title";
-    $s = stormperson_access_sql($s);
-    $s = db_rewrite_sql($s);
-    $r = db_query($s, $organization_nid);
-
-    while ($item = db_fetch_object($r)) {
-      $nid = $item->nid;
-      $people[$nid] = $item->title;
+      $query = db_select('node', 'n')
+        ->fields('n', array('nid', 'title'))
+        ->condition('n.status', 1)
+        ->condition('n.type', 'organization')
+        ->condition('spe.organization', $organization_nid)
+        ->join('stormperson', 'spe', 'n.vid = spe.vid');
+
+  $result = $query->execute();
+    foreach($result as $row) {
+      $nid = $row->name;
+      $people[$nid] = $row->title;

Needs to be tagged for a node_access check.

+++ b/stormperson/stormperson.module
@@ -509,7 +524,8 @@ function stormperson_update($node) {
-  $ass_user = user_load(array('name' => $node->user_name));
+  $username = $node->username;

$node->username or $node->user_name ?

Status:Needs work» Needs review
StatusFileSize
new5.38 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/storm/stormorganization/stormorganization.admin.inc.
[ View ]

Maybe this'll do the job :)

Status:Needs review» Needs work

The last submitted patch, storm-1799550-sqlapi-d7.patch, failed testing.

Status:Needs work» Needs review

#13: storm-1799550-sqlapi-d7.patch queued for re-testing.

StatusFileSize
new11.08 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

Ok, hopefully this is good :)

Status:Needs review» Needs work

Looks like there is an old patch included in the diff!

Also - would you be able to briefly explain the parts that this fix to aid in testing?

StatusFileSize
new5.38 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

Yup surely!

This should repair the "User" auto complete field in the "Add Storm Person" form - although - stormperson_insert() does not properly insert the user_uid correctly.

It may seem like stormperson_validate() is broken.

stormperson_validate() is not broken! If you manually set the user_uid in the db, for a Storm Person, to match the uid of a drupal user - you'll see it works correctly. i.e. You should not get this user returned in the "User" autocomplete field.

If you manually type the Drupal Users name in to the User field and submit, it will correctly throw form_set_error() as it should.

I could really use some help in getting the rest of stormperson.module sorted!

Status:Needs work» Needs review
StatusFileSize
new5.38 KB
PASSED: [[SimpleTest]]: [MySQL] 326 pass(es).
[ View ]

D'oh, let's test this puppy :)

I tried to test this, but the Storm Person form isn't really working yet so I didn't see a form.

Do you see a form etc?

Yes, insofar I see Salutation, Name, Username, Email, Phone...

I'll take another look at this when I get home!

I don't see those fields - so wondering if you've fixed this bit on your dev version?

Hi julian, I guess that must be fixed in this patch: http://drupal.org/node/1798036#comment-6629906

Status:Needs review» Fixed

Once I'd a) committed your other patch and b) refreshed my storm install the fields were there! Not sure which fixed, but meant that I tested and committed your patch.

For me, it inserted the user_uid correctly, but throws an error on the user_nid. After some investigations, I found this was a bug present in 6.x-2.x also. Will create a separate issue for that.

What are you going to work on next? ;-)

Getting you in to #drupal-storm when you are around :P

Hah!

Status:Fixed» Closed (fixed)

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