Download & Extend

Features Integration

Project:Menu token
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:closed (fixed)
Issue tags:Features integration, needs backport to D6

Issue Summary

So has anyone tried exporting these tokenized menu links to a feature... it doesn't work. What's necessary for features export?

Comments

#1

In the 7.x-1.0-alpha3 we have updated how menu_items is stored. It should integrate fine with Features. To make this possible for D6 version we must backport this functionality, see http://drupal.org/node/973882

#2

Doing the backport now locally. Will post when complete.

#3

This patch moves the 6.x branch to the new storage method but it still doesn't export correctly to features. No idea why.

AttachmentSize
patch_commit_d69e2c68dc9d.patch 34.77 KB

#4

Writing features integration with UUID. If you want to give me commit priv's to the 6.x branch, i'll commit some of this...???

#5

Experimental Features Support

AttachmentSize
experimental_features_support.patch 10.45 KB

#6

I have just checked how features works with menu token 7.x-1.0-alpha3. It works ok if there is single menu token item in the menu. This is because of issue of Features module http://drupal.org/node/927566. If this issue will be fixed Menu Token for D7 will have this integration. BTW, this issue does not only affect on Menu Token, it will affects on Internationalized menu; Do you think this issue could be easilty fixed with unique id?

Regarding your patch, it looks ok, and I really apriciate your help. However it could not be commited cause of this reason:

We need to backport changes done in 7.x-1.0-alpha3 to D6 version of this module. Why? Cause we changed the way how menu token settings are stored. We dropped menu_token talbe and now store settings in the options field of menu_links table, it allow to gain the perfromance and to use native Drupal caching. Also this allows not to write exporting/importing functions of this settings.

So IMHO after we will update D6 version of this module, all we need is to patch features to support unique id? What do you think?

#7

Version:6.x-1.x-dev» 7.x-1.x-dev
Issue tags:+needs backport to D6

#8

Unfortunately, the only way to get everything to work with UUID is to have some table where the UUID is matched up with the NodeID. You can't do a query on the UUID when it's stored in the Options field.

#9

Ok, so this patch adds UUID to the menu_links table instead of menu_token and eliminates the menu_token table entirely. Be sure to patch this to the original D6 DEV branch and ignore/disregard any earlier patches in this issue que.

AttachmentSize
patch_commit_39e006eee4ae.patch 44.06 KB

#10

Hello stovak.

This patch works with the 6.1.1 version or we must to go back to 6-dev version?

thanks

Oskar

#11

Status:active» needs work

stovak: The patch brings things a lot closer, but it doesn't seem to be there yet.

The first DB update had a bunch of errors (which I'll paste below); the second one succeeded apparently.

Output follows, but keep reading afterward:

:~/public_html/vbs/sites/all/modules$ cd menu_token/
:~/public_html/vbs/sites/all/modules/menu_token$ wget http://drupal.org/files/patch_commit_39e006eee4ae.patch
--2012-02-12
20:27:55--  http://drupal.org/files/patch_commit_39e006eee4ae.patch
Resolving
drupal.org... 140.211.166.6, 140.211.166.21, 140.211.10.16
Connecting to drupal.org|140.211.166.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45122 (44K) [text/plain]
Saving to: `patch_commit_39e006eee4ae.patch'

100%[============================================================================>] 45,122       208K/s   in 0.2s

2012-02-12 20:27:56 (208 KB/s) - `patch_commit_39e006eee4ae.patch' saved [45122/45122]

:~/public_html/vbs/sites/all/modules/menu_token$ patch < patch_commit_39e006eee4ae.patch
patching file menu_token.admin.inc
patching file menu_token.features.inc
patching file menu_token.inc
patching file menu_token.info
Hunk #1 succeeded at 1 with fuzz 2.
patching file menu_token.install
patching file menu_token.module
patching file menu_token_node_context.inc
patching file menu_token_node_random.inc
patching file menu_token_node_user_defined.inc
patching file menu_token_term_context.inc
patching file menu_token_term_random.inc
patching file menu_token_term_user_defined.inc
patching file menu_token_user_context.inc
patching file menu_token_user_random.inc
patching file menu_token_user_user_defined.inc
:~/public_html/vbs/sites/all/modules/menu_token$ drush updb
The following updates are pending:

menu_token module
6001 - description not available
6002 - description not available


Do you wish to run all pending updates? (y/n): y
Executing menu_token_update_6001                                                                           [success]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for   [warning]
the right syntax to use near &#039;DEFAULT NULL&#039; at line 1
query: ALTER TABLE menu_token ADD `uuid`  DEFAULT NULL database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59833d61-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 13079
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59889953-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14009
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;598c8a08-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14010
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59903452-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14012
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;5993212d-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14013
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;5996bea4-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14461
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599a677a-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14463
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599ce828-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14464
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599fad20-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14465
database.mysqli.inc:147
ALTER TABLE {menu_token} ADD `uuid`  DEFAULT NULL                                                          [error]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]

'all' cache was cleared                                                                                    [success]
Finished performing updates.                                                                               [ok]
:~/public_html/vbs/sites/all/modules/menu_token$ drush updb
The following updates are pending:

menu_token module
6002 - description not available


Do you wish to run all pending updates? (y/n): y
Executing menu_token_update_6002                                                                           [success]
ALTER TABLE {menu_links} ADD `uuid` VARCHAR(64) DEFAULT NULL                                               [success]
add field uuid to menu_links                                                                               [success]
drop table if exists menu_token                                                                            [success]

'all' cache was cleared                                                                                    [success]
Finished performing updates.                                                                               [ok]

The actual integration is also flawed. I have 8 or 10 menu_token-using menu items to featurize, but only 5 show up. Of the ones that show up, 3 of them don't use menu_token and the other two say they are just pointing to (at least in the Features output). A completely unrelated menu item appears in the menu_token component type that's appeared after applying the patch. Hope this test helps and contains sufficient detail.

#12

Am just using this module for a day, and took a fresh look. I found a completely new way to make this work. I might have overlooked something, but here is my approach.

Currently, menu_token stores the < front > variable in the path of every menu item. This is pretty convenient, as upon save of the menu item, Drupal checks if you have access to the path. There are very few websites where you dont have access to < front >. Upon rendering of the menuitem, menu_token replaces < front > with the calculated path based on the user_menu path tokens. This is a nice trick. However, the features menu export gives every menu a unique ID based on the name of the menu and the path. So if you have 2 menu_token enabled menuitems in 1 menu, the second one is not exported.

So, here is what i did:

  • Instead of < front > we store menutoken/[ a generated uuid] in the path of the menuitem
  • A hook_menu allows access to menutoken/%
  • In the menu item edit form, we hide the generated uuid, so its not regenerated on every save.
  • For parents, we check whether features is calling us or not. If features is calling us, we do not replace the path variable. This makes sure that the parent path is 'menutoken/[ a generated uuid] and not the generated path.

This works for me so far. Without changing features. But its pretty funky, so feedback is welcome.

I will need to test this with the menu_per_role module later.

(fixed some html formatting)

AttachmentSize
1289302_12_menu_token_features.patch 4.84 KB

#13

Status:needs work» needs review

The patch need to be review?

#14

I'm confused. Are these patches for Drupal 6 or 7? I'm using 7.x-1.0-beta and the menu links for features export don't appear when I check the use tokens box in for the menu link.

#15

#12 is for Drupal 7.

#16

Version:7.x-1.x-dev» 7.x-1.0-beta1

#12 does not apply cleanly to beta1

#17

Version:7.x-1.0-beta1» 7.x-1.x-dev
Priority:normal» critical

Working on patch at #12

#18

Patch re-rolled and pushed to 7.x-1289302 branch. Also, added an update hook that fixes current menu items that are using tokens.

Patch attached for your review. Let's make it RTBC!

AttachmentSize
menu_token_features.patch 5.74 KB

#19

Status:needs review» needs work

#20

Status:needs work» reviewed & tested by the community

Issue #1896834: CTools Export Bonus integration confirms that the patch works. To be committed pretty soon.

#21

Status:reviewed & tested by the community» needs work

Patch created in Drupal Camp Cartagena.

Please, needs work.

AttachmentSize
menutoken-cartagena-1289302-6853908.patch 5.74 KB

#22

Component:Miscellaneous» Code
Status:needs work» fixed

Patch committed and new release published!

#23

#24

Status:fixed» needs work

#25

I think instead of doing debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), you can just do debug_backtrace(), as all that this code uses is the function name... if you want to save memory then check first if the constant is set.

Besides that, this whole function seems to be a gruesome hack, but I don't know how necessary it is.

#26

#27

Status:needs work» fixed

#28

Status:fixed» closed (fixed)

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

nobody click here