See plugin.js

tagCache[tag_id].tag is empty when trying to edit or override asset (assetOverride and assetEdit fucntions). It's a bug, because asset is already loaded in wysiwyg, but cache wasn't set.

As result in function getTagData() we get 2:image:1358916609720 instead of [[asset:audio:5 {"mode":"full","align":""}]] and see warning - Uncaught TypeError: Cannot read property 'tag' of undefined plugin.js:406 . See attached screenshot.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agalitsyn’s picture

If to override an asset and switch wysiwyg input mode to plain text and back to rich text 2 times overrides will be discharged

1st time asset takes from cache, but second will be added using ajax request without respect to overrides

agalitsyn’s picture

Status: Active » Fixed
FileSize
4.13 KB

Fixed, will be pushed to dev branch

agalitsyn’s picture

Status: Fixed » Closed (fixed)

Pushed to dev

carlosmossman’s picture

After applying this patch, I am still unable to edit an asset which was previously saved. If I create a new asset, it's correctly added to the cache but, when the editor initializes, my existing existing assets fail to cache.

I never see [[asset:]] markup, which I presume the module requires, given its regular expression. Is this expected to work when the parsed content is HTML?

I have tested with and without "Remote asset tags from markup" and "Convert asset tags to Markup" for the relevant Text Formats.

The error I get is "Uncaught TypeError: Cannot read property 'tag' of undefined"

Any suggestions are appreciated.

kholloway’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
549 bytes

This is definitely still a bug but I was able to resolve it with the included patch.

Versions:
Ckeditor Version: 4.4.3
Asset Version: 7.x-1.0-beta4+26-dev

To reproduce:
- Add an image asset to a node through the WYSIWYG editor (used full html which has no filters applied besides Asset translation)
- Right after the asset is added (before you save/create the node) right click the asset to verify you can select "Edit Asset" and it still works
- Now save the node
- Edit that saved node
- Right click the asset in the WYSIWYG editor that was created previously
- Select "Edit Asset"
You should then get the JS error stated previously: "Uncaught TypeError: Cannot read property 'tag' of undefined plugin.js"

The patch I added is actually adding a code segment that was removed with the previous patch to the assetEdit code segment. Hope this helps :)

EDIT:
In case it matters I am using the Workbench module as well (workbench moderate). Not sure if this somehow causes problems in that there are various stages of one content item ;)

kholloway’s picture

FileSize
1.06 KB

Actually I realized the same patch needs to be applied for the "Override Asset" functionality as well. Updating the patch to include that fix too.

nghai’s picture

Hi @Kholloway, I also faced this problem while working on a project that time I applied the same solution of calling the alternative function "Assets.getDataById" when the tagCache is undefined.

But even with this solution the problem is not completely solved. That patch only helps in removing those errors from console and loading assets dialogs without any trouble. But the content loaded inside the dialog box is not correct. It takes default values as the tagCache is undefined which contains the correct/selected values.

For example: "Display mode" of the embedded asset. I take the same test case as you described above:

- Add an image asset to a node through the WYSIWYG editor with non-default view mode(for this there should be at least two or more view modes enabled for the editor)
- Right after the asset is added (before you save/create the node) right click the asset to verify if the selected non-default view mode is there.
- Now save the node
- Edit that saved node
- Right click the asset in the WYSIWYG editor that was created previously
- See the "Display mode" instead of the actual selected non-default view mode the default option will be there as selected.

It happens because the "getDataById: function (tagId, viewMode, align)" the viewMode is not provided and the real call: "'admin/assets/override?render=popup&tag=' + tag" is not working due to undefined tagCache.

PS: I am still working on an old version of the module: "7.x-1.0-beta4+4-dev" because of the project complexities. If you not facing this kind of problem then please let me know.

eugene.ilyin’s picture

@kholloway, I've updated your patch to make it applicable for 7.x-1.x-dev version and also I corrected one more problem

@nghai, maybe better is create new issue for this problem?

IRuslan’s picture

Status: Needs review » Needs work

I agree with @nghai, it's just turn the problem into silent mode.
Normal behavior is next. During CKEditor afterInit for all assets within field called in Assets.attach we retrieve data and build cache.
In this.getContentByTag(clean_tag) for each asset request is made and put it into cache.
Later any asset should be found in cache. So as any action with assets will be made later then cache building.
But i believe the problem is that starting from some CKEditor versions afterInit or dataFilter within afterInit stopped to work.

eugene.ilyin’s picture

Mhhh, I've downloaded the last dev version of module asset and seems this problem isn't reproduced more.
Can anybody help me with testing?

nghai’s picture

Sure, I will download the latest version of the module and test with the real scenario.

brad.bulger’s picture

I still see this problem. I've rerolled the patch for the current code - 7.x-1.0+11-dev