I enable in place editing and click either 'customize this page' or 'change layout' and I get the following error:

An error occurred while attempting to process /panels/ajax/ipe/save_form/panel_context%3Apage-events_upcoming%3Apage_sng_online_conferences_upcoming_panel_context: this.ipeReplacedBeforeSerialize is not a function

Comments

Letharion’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Clearly this doesn't happen to everyone. You need to show how others can reproduce the problem.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
socialnicheguru’s picture

this is an interaction with nodejs and I'm trying to investigate

socialnicheguru’s picture

Issue summary: View changes
Status: Closed (cannot reproduce) » Active
Issue tags: +panels, +panelizer, +panels_ipe, +nodejs js javascript drupal7 error

Enable panels_ipe
Enable for specific content type
Create a node and click save
Two buttons will appear: "Customize this page" and "Change this layout"
When I click on either one of these without nodejs enabled, all is good in the world. The page layout and/or content can be changed in line.

Now I enable nodejs and configure it correctly for the same site.
When I goto the above node and click either of the buttons I get the error:

An error occurred while attempting to process /panels/ajax/ipe/save_form/panelizer%3Anode%3A9%3Apage_manager: this.ipeReplacedBeforeSerialize is not a function

There is some type of conflict between nodejs and panels_ipe.
(On another note: the url for the error looks odd. '%3A' which I assume is ascii for '/' is only added after the panelizer portion)

socialnicheguru’s picture

Project: Panels » Node.js integration
Version: 7.x-3.x-dev » 7.x-1.x-dev
Component: In-Place Editor (IPE) » Code
Category: Support request » Bug report

moving to nodejs queue since disabling nodejs causes the error to go away.

similar issue:
https://drupal.org/node/2056891

socialnicheguru’s picture

Title: this.ipeReplacedBeforeSerialize is not a function » nodejs screws up panels in place editing: this.ipeReplacedBeforeSerialize is not a function

update title

hatsch’s picture

i can confirm this issue. since i've installed nodejs IPE stopped working.

Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

Node.js monkey-patches Drupal.ajax:

http://drupalcode.org/project/nodejs.git/blob/refs/heads/7.x-1.x:/nodejs...

i guess that causes issues? NFI why.

can someone point me at the js code in panels_ipe that breaks?

cmonnow’s picture

Hi,

I assume the conflicting code in panels_ipe is the following in panels_ipe/js/panels_ipe.js?

 Drupal.ajax.prototype.ipeReplacedBeforeSerialize = Drupal.ajax.prototype.beforeSerialize;
Drupal.ajax.prototype.beforeSerialize = function (element_settings, options) {
if ($(this.element).attr('id') == 'panels-ipe-save') {
Drupal.PanelsIPE.editors[this.element_settings.ipe_cache_key].saveEditing();
};
return this.ipeReplacedBeforeSerialize(element_settings, options);
}; 

Based upon javascript console results:
panels_ipe's Drupal.ajax.prototype.ipeReplacedBeforeSerialize references the original ajax function first (before the nodejs.js override).
Then nodejs.js's Drupal.Nodejs.originalBeforeSerialize references the already over-written Drupal.ajax.prototype.beforeSerialize, before over-writing it once again with its own code that happens to reference the over-written fake original from panels_ipe that contained this.ipeReplacedBeforeSerialize.

Should panels_ipe.js simply be returning Drupal.ajax.prototype.ipeReplacedBeforeSerialize(element_settings, options) instead?

Cheers

socialnicheguru’s picture

Status: Postponed (maintainer needs more info) » Active
Anonymous’s picture

thanks for digging in.

i'm not sure what the right answer is, i'm not really familiar with this js pattern. i'll ask some people who should know.

socialnicheguru’s picture

The tweak in #9 did not work for me.

cmonnow’s picture

That's a shame. I'm using Panel 7.x-3.3 as part of some old Panopoly distro. Admittedly, I haven't tried saving anything (and I'm afraid to try - since I don't use IPE anyway) but the error has disappeared in my case and the customize and change layout buttons appear to work normally.


  Drupal.ajax.prototype.ipeReplacedBeforeSerialize = Drupal.ajax.prototype.beforeSerialize;
  Drupal.ajax.prototype.beforeSerialize = function (element_settings, options) {
    if ($(this.element).attr('id') == 'panels-ipe-save') {
      Drupal.PanelsIPE.editors[this.element_settings.ipe_cache_key].saveEditing();
    };
    return Drupal.ajax.prototype.ipeReplacedBeforeSerialize(element_settings, options);
  };

});
socialnicheguru’s picture

I tried #13 and it seems to work.

Anonymous’s picture

Status: Active » Closed (won't fix)

ok, closing based on #14.

mike.darke’s picture

Status: Closed (won't fix) » Active
StatusFileSize
new1022 bytes

I've just come across this same issue. I tried updating as per #13 and while this fixed the issue which prevented the panels dialog from opening there still remains a problem where updating or adding panels does not save so I am re-opening the ticket.

The issue is caused because the scope of "this" is changed by the Nodejs implementation of beforeSerialize, when Drupal.Nodejs.originalBeforeSerialize is called the scope of "this" is changed from the Drupal.ajax object to the Drupal.Nodejs object. This results in the panels_ipe saveEditing function not getting called.

To fix this I assigned the originalBeforeSerialize function to the Drupal.ajax prototype and then call it with "this" within the overridden beforeSerialize function, this is the same technique that is used by panels_ipe.js. This way the scope is maintained and the panels can be saved. Also this does not require the change in #13 to the panels_ipe.js.

Importantly, this would also potentially fix any interoperability issues with this module and any others that override the Drupal.ajax.beforeSerialize function. Here is the code I updated...

      Drupal.ajax.prototype.nodejsOriginalBeforeSerialize = Drupal.ajax.prototype.beforeSerialize;
      Drupal.ajax.prototype.beforeSerialize = function(element_settings, options) {
        options.data['nodejs_client_socket_id'] = Drupal.Nodejs.socket.socket.sessionid;
        return this.nodejsOriginalBeforeSerialize(element_settings, options);
      };
Anonymous’s picture

thanks for the patch, i'll look at it today.

Anonymous’s picture

Status: Active » Needs review
socialnicheguru’s picture

path in #16 seems to work with the following version:
; Information added by Drupal.org packaging script on 2014-03-25
version = "7.x-1.7+3-dev"

  • beejeebus committed d02375b on 7.x-1.x
    #1674198: Fix Drupal.ajax monkey patching code so it plays nicely with...
Anonymous’s picture

Status: Needs review » Fixed

thanks, committed the patch in #16.

Status: Fixed » Closed (fixed)

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

cmonnow’s picture

Priority: Normal » Major
Status: Closed (fixed) » Needs work

The on disconnect function needs to be updated with the new name as well (a serious side effect of this bug is that if the node.js server becomes disconnected then Drupal.ajax.prototype.beforeSerialize becomes 'undefined' and all AJAX requests will subsequently fail even after reconnection).

  Drupal.Nodejs.socket.on('disconnect', function() {
    Drupal.Nodejs.runSetupHandlers('disconnect');
    if (Drupal.ajax != undefined) {
      Drupal.ajax.prototype.beforeSerialize = Drupal.Nodejs.originalBeforeSerialize;
    }
  })

;

should be changed to:

  Drupal.Nodejs.socket.on('disconnect', function() {
    Drupal.Nodejs.runSetupHandlers('disconnect');
    if (Drupal.ajax != undefined) {
	Drupal.ajax.prototype.beforeSerialize = Drupal.ajax.prototype.nodejsOriginalBeforeSerialize;
    }
  });

(Convention-wise, should I post the patch to a new thread for a "closed (fixed)" topic?).

P.S. Thanks to Firebug's profiling feature for making my debugging easier...

damienmckenna’s picture

Issue tags: -panels_ipe, -nodejs js javascript drupal7 error +ipe, +nodejs, +JS, +JavaScript
socialnicheguru’s picture

i had to make the fix outlined in #23. works

cmonnow’s picture

Status: Needs work » Needs review
StatusFileSize
new592 bytes

Cheers. I've attached #23's equivalent in patch.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

#26 solves the issue for me. The patch applies cleanly to the latest dev.

Zemelia’s picture

StatusFileSize
new806 bytes

Hi, issue appears on latest dev version.
Error message: "Cannot read property 'sessionid' of undefined"
Patch attached.

Zemelia’s picture

Status: Reviewed & tested by the community » Needs review
Anonymous’s picture

Status: Needs review » Fixed

thanks, committed and pushed to 7.x-1.x.

  • beejeebus committed fd47fe2 on 7.x-1.x authored by Zemelia
    Issue #1674198 by cmonnow, Zemelia, mike.darke: nodejs screws up panels...

Status: Fixed » Closed (fixed)

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