Problem/Motivation

See attached screen shot for error. Line 357 in the content_lock.module is the below:

'ajax_key' => $lock->ajax_key, 'token' => $token,

I get this when I edit a document, and then another user stumbles upon my locked document, and then I clicked cancel to stop editing.

Steps to reproduce:

  • User A has the Check Out/Lock Documents permission
  • User B has the Administer Checked Out Documents permission in addition to the Check Out/Lock Documents permission
  • PHP error notices need to be output to the screen
  1. As User A edit a node
  2. Assert you have the lock
  3. As User B locate the node and break the lock (use the link in the Drupal Warning)
  4. Assert User B is on the edit form
  5. As User A attempt to save the node
  6. Assert you get a Drupal Error informing you about the broken lock and User B's position.
  7. As User B click away from the edit form, click Leave this page when challenged.
  8. As User A attempt to save the page again
  9. Assert the save was successful
  10. Assert the above error message is displayed.

Proposed resolution

Replace the $lock->ajax_key with a variable.

Remaining tasks

Patch submission and peer-review

User interface changes

None.

API changes

None.

Comments

jaydub’s picture

Status: Active » Postponed (maintainer needs more info)

I can't get the same error but perhaps if you give a bit more detail.

So steps are:

* User A with permission to lock edits node
* User B with permission to lock(?) views locked node (node/XX) OR tries to edit locked node (node/XXX/edit)??
* User A clicks cancel to get out of edit mode
* User A sees the error message? On the node page (node/XX) after clicking cancel and being redirected?

alfaguru’s picture

It seems that this happens whenever a node was locked when a form was created but the lock has gone by the time it is submitted. I managed to reproduce this by opening the same edit form twice in different windows within a browser session and then submitting both of them. On the second this error appears.

Looking at the code, it doesn't cope with the the case where content_lock_fetch_lock() returns an empty value. It would seem sensible that it should.

drupalninja99’s picture

I am getting this issue too.

gold’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new880 bytes

And now the patch...

This takes the result of loading the lock and loads either $lock->ajax_key or FALSE into a variable to pass into the $settings array.

gold’s picture

I've just checked this using drush make with the following build.make snippet;

; Content lock
projects[content_lock][type] = module
projects[content_lock][subdir] = contrib
projects[content_lock][download][type] = git
projects[content_lock][download][revision] = 7.x-1.x
; http://drupal.org/node/1530620
projects[content_lock][patch][] = "http://drupal.org/files/content_lock-fix_notice-1530620-4.patch"

The result was successful. Drush make reports;

gold@shipnet ~/Projects/mts (gold/master) $ drush make --no-core --projects=content_lock build.make 
Make new site in the current directory? (y/n): y
Drush make restricted to the following entries:                                                              [ok]
Projects: content_lock
content_lock cloned from http://git.drupal.org/project/content_lock.git.                                     [ok]
Checked out revision 7.x-1.x.                                                                                [ok]
content_lock patched with content_lock-fix_notice-1530620-4.patch.                                           [ok]
Generated PATCHES.txt file for content_lock                                                                  [ok]

Running the above steps in the description does not return any notices now.

I'm not the appropriate one to test this though. Could someone else please test and update the Status.

gold’s picture

Status: Needs review » Needs work

Hmm... Have spotted a second this like this. Will roll it into this patch soon.

gold’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB

Adding to the fix in #4 to also include one from the content_lock_release_own_item() function. Tidied up a drupal_set_message() that is never reached also.

gold’s picture

Issue summary: View changes

Updating with a proper issue summary template

jastraat’s picture

Version: 7.x-1.x-dev » 7.x-2.0
Status: Needs review » Reviewed & tested by the community

This still applied to the current version, and it prevents the ajax error.

pandaski’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
pandaski’s picture

Issue tags: +7.x-2.1

  • Joseph Zhao committed 84ea2b6 on 7.x-2.x
    Issue #1530620 by Gold: Notice: Trying to get property of non-object in...
pandaski’s picture

Status: Patch (to be ported) » Fixed

Thanks guys, will be in next release very soon.

  • Joseph Zhao committed 84ea2b6 on 7.x-3.x
    Issue #1530620 by Gold: Notice: Trying to get property of non-object in...
drumm’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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