For converting existing sites to use Mongo, re-creating the views along with configuring the pages/context/blocks/CSS classes/etc can be a huge pain, so let's offer a way to just switch existing views to use EFQ.

This is a *very* early version that just addresses some of the obvious cases but is working fine for simple views and is ready for some early review. Note that it's NODE ONLY at this point--it does nothing for user/taxo/etc views yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mcrittenden’s picture

Status: Needs review » Needs work

@chx and @dawehner on IRC both said the general direction looks OK. chx mentioned that we need some sort of error reporting. So since I'm heading in the right direction, I'm setting back to CNW.

mcrittenden’s picture

Status: Needs work » Needs review
FileSize
6.66 KB

Update: this works well for me. It warns you on views that have relationships and does not alter those, and processes the rest of the node views. I have successfully converted like 15 real world views with filters/sorts/global text fields/arguments/etc with it.

The code needs a refactoring/cleanup which isn't a big deal but I think I'm ready for review.

(I'm just uploading the file instead of generating a useless patch)

mcrittenden’s picture

Status: Needs review » Needs work

Review from chx on IRC:

(03:17:54 PM) chx: mcrittenden: array_slice($fields, $pos + 1, 100, TRUE); <= why not NULL?
(03:18:36 PM) chx: mcrittenden: if (!strstr($field['table'], 'views')) { <= i know that core does this and i absolutley hate it -- use strpos for heaven's sake
(03:18:52 PM) chx: mcrittenden: if (strpos($field['table'], 'views') !== FALSE)
(03:20:20 PM) chx: mcrittenden: if (strstr($filtername, '_tid') || strstr($filtername, '_target_id')) { same strpos
(03:21:56 PM) chx: mcrittenden: aside from relationships, it's the base table as well
(03:22:29 PM) mcrittenden: chx: not sure what you mean? what is the base table?
(03:23:43 PM) chx: mcrittenden: and altogether you should try to validate the view before saving
(03:23:56 PM) chx: mcrittenden: if ($view->base_table == 'node') { $view->base_table = 'efq_node';
(03:24:03 PM) chx: mcrittenden: well, it could be many other things
(03:25:17 PM) chx: mcrittenden: it should be something $new_base_table = 'efq_' . $view->base_table; if (!views_fetch_data($new_base_table)) { error; continue;}
(03:26:06 PM) chx: mcrittenden: and all the things you convert, you should be calling views_get_handler on each of them to see whether it'll work
(03:26:34 PM) chx: mcrittenden: and *still* you should call $view->validate() before ->save()
(03:29:18 PM) chx: mcrittenden: } else if ($fieldname == 'totalcount') { this needs to be newline
(03:29:26 PM) chx: mcrittenden: } else { same

mcrittenden’s picture

Assigned: mcrittenden » Unassigned

Looks like I won't be able to work on this for awhile so un-assigning myself. The existing script worked for 95% of cases on about 20 fairly complex views. The other 5% is easy to recognize by looking for "Broken/missing handler" on a field or filter or whatever on views that you've converted, and from there it's very simple to fix.

If anyone wants to pick this up, just follow chx's instructions above.