Hi There,

Apologies if I'm not posting in the correct area.

Summary: Upgraded from D6 to D7 (Nightmare). Error when trying to edit existing document node.

Users can successfully upload new documents but cannot edit existing.

When a user comes to save, the error 'A new document cannot be specified without creating a new revision first'.

If I switch on error reporting, I get the following extra information:

Notice: Undefined property: stdClass::$revision in document_validate() (line 259 of /var/www/sites/portal/sites/all/modules/document/document.module).
Notice: Undefined property: stdClass::$revision in document_validate() (line 290 of /var/www/sites/portal/sites/all/modules/document/document.module).
Notice: Undefined property: stdClass::$revision in document_validate() (line 298 of /var/www/sites/portal/sites/all/modules/document/document.module).

I've looked in the document, node and revision tables and cannot see any data regarding the attempted change.

I've ensured 'create new revision, no moderation' is selected during the edit process. In addition I've ensured 'Create new revision' is selected as the default option in document type settings. We do not make use of the draft/moderation functionality so this is currently unchecked.

Any advice is greatly appreciated.

Comments

wookiemonster’s picture

I should point out that revisions work fine with normal page-like nodes.

wookiemonster’s picture

By updating php on the lines indicated in the error information to isset as opposed to relying on the default declared/not declared option has fixed the notices.

I still however have the problem regarding updates to the document. I cannot choose and upload a new document revision.

All I get is the above mentioned error:
'A new document cannot be specified without creating a new revision first'.

wookiemonster’s picture

As much as I didn't want to, I've resolved the issue by declaring revision in the document module as 1 (Assumed Bool). $node->revision=1

if ($hasDoc) { 
	
	// Assumed forced revisioning?
	$node->revision=1;
	
	if (isset($node->nid) && !$node->revision) {
	 
      //A new document cannot be uploaded without creating a revision.
      form_set_error('document_filepath', t('A new document cannot be specified without creating a new Revision for an existing node.'));
    }
  }

The user is now able to successfully upload a new document, which is stored and renamed if needed.