menu_get_item() that is used in the module doesn't handle url language prefix. I fixed that but after that when wysiwyg+tinymce restores text it looks smaller though HTML button shows the HTML is the same. And when Save button is pressed, it turns out that form action is changed by prepending the language prefix, e.g. from bg/node/1/edit it's changed to bg/bg/node/1/edit and naturally Page not found error is shown.

Anyway, I'm attaching my fix for menu_get_item().

Comments

quicksketch’s picture

Are you reporting two separate problems here? I'm not clear on whether two problems should be fixed. If so, please open a second issue with that problem. Regarding the language prefix problems, could you describe how to reproduce the problem? I think you may be describing #1617032: After restoring a form, subsequent autosaves written to db with wrong path.

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new2.28 KB

Thanks for reporting this problem with the language path prefix. I could confirm the problem (autosave basically didn't work when using a language prefix), and the fix worked great. I cleaned up the formatting a little more and committed the attached patch. I made a separate issue for what I think you described over in #1678806: Fonts/CSS don't apply properly after loading an autosave. Thanks!

Status: Fixed » Closed (fixed)

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

hey_germano’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new1.41 KB

On a site with only one language, I was getting this error when trying to restore an autosave revision:

PHP Fatal error: Call to undefined function language_negotiation_get_any() in /path/to/drupal/sites/all/modules/contrib/autosave/autosave.module on line 379

I read through some API stuff, and it looks like language.inc is only included on sites with multiple languages. So on sites with just one, I believe that error will always come up. It was preventing the autosave functionality from happening at all.

This patch just has a wrapper around that language function that checks if you've got multiple languages running or not. Fixed the issue for me, at least (running latest dev version of autosave).

pumpkinkid’s picture

I had the problem described in #4 until I applied the patch...

I was seeing this problem on a brand new node creation form and when it would come up for restore, it would error out.

As soon as I applied the patch in #4, I was able to restore the autosave, but it does not continue to autosave past that point.

Also, using admin overlay, the restore makes the overlay much bigger than it needs to be.

agentrickard’s picture

Status: Needs review » Needs work

Makes sense, but no need to nest the initial IF statements. This is perfectly readable:

  if (drupal_multilingual() && language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_URL)) {
deciphered’s picture

Status: Needs work » Needs review
StatusFileSize
new708 bytes

Re-rolled patch with the suggested change and a fix for the patch base directory.

agentrickard’s picture

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

Status: Reviewed & tested by the community » Needs work

Still does'nt work for me with patch in #7 (7.x-2.x-dev)
Save button link to the page adding the default language prefix to the correct url (and of course doesn't save restored version) :
If I'm editing "/en/node/nodeid" it link to "/en/en/node/nodeid".
If I'm editing "/fr/node/nodeid" it link to "/en/fr/node/nodeid".
Notice when I'm on a french node form, the Save button is labeled "Enregistrer" and after I click the restore link, Save button label become "Save".

mikemadison’s picture

I can confirm that the patch in #7 does fix the "importing of autosaved" data issue, but I can also confirm that once doing that autosave no longer seems to function.

Autosave continues to function just fine on pages that have not been restored.

gugalamaciek’s picture

Version: 7.x-2.x-dev » 7.x-2.1

I've installed new 2.1 verison of the module and I have still problem similar to described in comment #9.

When I click to restore form and then save form using button, it redirects me to page e.g. /en/en/node/nodeid instead of /en/node/nodeid.

I'm using drupal 7.18 on IIS7.5, MSSQL.

gugalamaciek’s picture

I've changed line 201 of autosave.module from:
$form['#action'] = url($record->path);
to:
$form['#action'] = '/' . $record->path;

I'm not sure if it's right way to do it, but it works for me.

dave reid’s picture

Status: Needs work » Fixed

I committed #7 since I was also getting the PHP fatal error on a fresh site install. Let's ensure any other follow-ups are filed as separate bug reports now since there seems to possibly be issues with saving on a multilingual site.

http://drupalcode.org/project/autosave.git/commit/48bce20

Status: Fixed » Closed (fixed)

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

plach’s picture

pixelpreview@gmail.com’s picture

the solution that works for me is :
line 228 in dev version
$form['#action'] = url($record->path, array('language' => array('language')));

If I add the array language in the url function, I don't have redirect like :
/en/nl/node/nodeid

g-brodiei’s picture

Version: 7.x-2.1 » 7.x-2.x-dev

I have the same condition of redirecting from /zh/add/webform/ to /zh/zh/add/webform when I try to save the node. Working on a multilanguage site using prefix.

The solution from @pixelreview worked for me.
added manually on line 315 in dev version, autosave.module file.

from
$form['#action'] = url($record->patch);

to

$form['#action'] = url($record->path, array('language' => array('language')));

Drupal 7.56
autosave 7.x-2.x-dev