When clearing the cache with Drush, I repeatedly keep seeing this error.

GMap is unable to save the marker bundle, so the markers will not work. Please check file system permissions of the public://js/gmap_markers.js!

.

I checked the permissions for over a dozen times just to make sure it's not me, but they are good. The same as all other files on public:// and those settings work.

Also I seems that every entity with a map attached to it, loads terribly slow. Some Views pages with event nodes on them take for over a minute (used to be 2-3 seconds). Something since 2.10 that could have caused this?

I deliberately did not post this in #2282939: SLOW loading a GMAP page because this issue appeared only after updating from 2.10 and as such cannot be related to the other issue (reported under 2.9).

Issue fork gmap-2693297

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Neograph734 created an issue. See original summary.

neograph734’s picture

Issue summary: View changes
neograph734’s picture

It looks like this commit in #2571855: Unlock gmap_regenerate_markers in cli mode is the only thing that can be related to this.

neograph734’s picture

Title: GMap is unable to save the marker bundle public://js/gmap_markers.js + decreased performance. » GMap is unable to save the marker bundle public://js/gmap_markers.js

It appeared the reduced speed was the cause of a failing hard drive. The write error remains though.

coolestdude1’s picture

Same issue for me, nginx - php-fpm - php5.6.
I have gone as far as checking /includes/file.inc and adding debug statements to the following function to see what was going on here is what I found.

In function: file_prepare_directory
If you add debugs to what is the directory and components being checked you will see firstly a check for 'public://js/' is writable, then another call to this function and the second time through it checks 'public://js', for some reason the newer version of gmap is checking if the folder is writable then checking to see if this 'js' file would be writable which seems very fishy to me.

I am not sure what in the latest update to gmap is causing this because in the old version it works to save the file just fine and not much of the code around this section has changed.

neograph734’s picture

All calls to file_prepare_directory I've found do not include the leading slash in the path.

function gmap_regenerate_markers() {
  $dir = 'public://js/';
  $filepath = $dir . 'gmap_markers.js';
  // Make sure js/ exists in the files folder.
  if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
   
  }
}

In above code you'll see that the path does include a leading slash, that gets fed into file_prepare_directory(). It might work better if we'd change that into:

  $dir = 'public://js';
  $filepath = $dir . '/gmap_markers.js';

I can test and patch this after the weekend.

johnv’s picture

The info in the following (closed) issues might help:
#1114164-72: Stop clearing markers so often: fixes Message: GMap is unable to save the marker bundle. Markers will not work!
#1167594-13: Saving gmap_markers.js needs catch errors
Try setting the file permissions to 777. The drush user is not the website user.
You can also try the link on : /admin/config/services/gmap

arruk’s picture

#7 worked for me. Specifically the directory js in /sites/default/files/ needs to be set to 777 for some reason...

neograph734’s picture

I suppose the advice to make any folder in your files directory writeable by everybody is generally bad practice. It should be writeable for your webserver and nobody else.

Warning

The most dangerous and least secure option is to assign write access to "everyone." This option should be avoided at all costs. If the steps outlined above do not work, please consider adjusting your hosting configuration (e.g. add your Web server to the appropriate group) instead of granting write access to "everyone."

Source The files directory

So I suppose it would be better to always have Drush ran by the webserver (rather than the ssh user you are using by default). http://drupal.stackexchange.com/questions/51436/drush-and-user-permissions explains you can do something like this:

sudo -u apache drush
or on debian/ubuntu:
sudo -u www-data drush

Might not be the best advice, but IMHO better then setting 777 on the files directory or a sub-directory.

And since this is a Drush / filesystem issue, I suppose this question should be closed as there is obviously nothing this module can do to change that.

jackalope’s picture

Version: 7.x-2.x-dev » 7.x-2.11
Status: Active » Needs review
StatusFileSize
new627 bytes

This problem has been around for a while in the Gmap module. This patch in an earlier issue about the problem has the right idea, but the patch no longer applies properly to gmap.module.

I've attached a new patch here that applies cleanly to Gmap 7.x-2.11 (let's see how it tests against 7.x-2.x-dev!

Status: Needs review » Needs work

The last submitted patch, 10: gmap_unable_save_marker_bundle_2693297-10.patch, failed testing.

mustanggb’s picture

Issue tags: +Needs reroll

Patch works perfectly, just needs to be rerolled from the module directory.

betz’s picture

Status: Needs work » Needs review
StatusFileSize
new535 bytes

patch rerolled, let's continue :)

betz’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 13: gmap_unable_save_marker_bundle_2693297-13.patch, failed testing.

jackalope’s picture

Thanks so much for the reroll--I know it sounds silly but I honestly hadn't been able to find the time myself!

I see the rerolled patch is still failing testing though; will try to give it a look soon...ish.

neograph734’s picture

Version: 7.x-2.11 » 7.x-2.x-dev
Status: Needs work » Needs review

Patches need to be built and tested against the latest development version. Let's see how it performs there.

Status: Needs review » Needs work

The last submitted patch, 13: gmap_unable_save_marker_bundle_2693297-13.patch, failed testing.

neograph734’s picture

It seems the development branch is broken, but not marked as such. The same test fails on all commits. This has been spotted here as well.

I have requested an issue with the Drupal.org infra team, maybe they can queue the development branch for re-testing. #2778705: Requesting a branch re-test of the gmap module

neograph734’s picture

neograph734’s picture

Status: Needs work » Needs review

The patch has been queued for re-testing as soon as the -dev branch is passing.

ahimsauzi’s picture

I have been getting this same error locally when my /tmp directory was not set up properly after bringing down remote db. Hope this helps.

mustanggb’s picture

Status: Needs review » Reviewed & tested by the community

Tests are passing and it fixes the Drush issue.

Chris Charlton’s picture

asiby’s picture

The patched worked for me. Kudos to everyone who contributed.

Eric Bouquerel’s picture

ikeigenwijs’s picture

pleas get this committed to dev

rakun’s picture

After patch https://www.drupal.org/files/issues/gmap_unable_save_marker_bundle_26932... I still get error message in watchdog "The file permissions could not be set on public://js/gmap_markers.js.". GMap module 7.x-2.11.

mustanggb’s picture

@rakun
It could be that your permissions are infact not set correctly, this patch is for people that have set their permissions correctly, but still have the message.

p4trizio’s picture

Patch #13 is working, I guess it's time to commit

Chris Charlton’s picture

+1

joegl’s picture

I've done EVERYTHING I could to fix this issue, after an upgrade from 2.9 to 2.11. I then found this StackOverflow comment: https://drupal.stackexchange.com/questions/97623/how-to-add-a-custom-mar...

Just thought I'd point out in the this somewhat long-running thread that, due to an update, Dmytro Pastovenskyi's answer is no longer valid in 7.x-2.11. The "Custom markers path" field is still present in the UI form at /admin/config/services/gmap, however any value entered there is effectively ignored. What I did to get it working:

Install the Libraries API module (https://www.drupal.org/project/libraries)
Create a directory in sites/all/libraries called "gmap_markers"
Put your ini file and any related images in this folder
Clear the caches

After getting the permissions resolved this is what finally actually did it for me.

donquixote’s picture

Status: Reviewed & tested by the community » Needs work

I think we should only commit a patch that fixes both this and #1978520: The file permissions could not be set on public://js/gmap_markers.js, in a way that you can clear the cache in drush/cli and in web without any warnings related to gmap_markers.js.

Problems with patch #13:

It does not solve the fundamental problem that a file or directory can either be owned by drush/cli user or by web user (www-data), not by both. Hence, you will get the "The file permissions could not be set on public://js/gmap_markers.js" either in drush cc all or in when flushing caches with the browser.

It changes the $filepath variable, but then this variable is not used anywhere (except in messages).
The file_save_data() call uses a hardcoded file path.

  $dir = drupal_realpath('public://js/');
  $filepath = $dir . 'gmap_markers.js';
  // Make sure js/ exists in the files folder.
  if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
    $file = file_save_data($contents, 'public://js/gmap_markers.js', FILE_EXISTS_REPLACE);

If we WERE to use the modified $filepath variable there, it would cause problems:

  1. The variable $filepath lacks a slash. It will be something like /path/to/drupal/sites/default/files/jsgmap_markers.js.
  2. Even with this slash fixed, we get 'The data could not be saved because the destination %destination is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.', because file_valid_stream() would reject the file path.

And finally, no one in this issue has so far explained which underlying problem is fixed by calling drupal_realpath().
Perhaps there is a good reason, but it deserves to be explained.

donquixote’s picture

@MustangGB (#29)

@rakun
It could be that your permissions are infact not set correctly, this patch is for people that have set their permissions correctly, but still have the message.

The "correct" permissions would be:
- File and directory owned by web user and group (www-data:www-data)
- For the sake of argument, let's give it directory and file 777.

With these permissions and ownership, drush cc all still produces errors from drupal_chmod(), unless you run drush as the web user (on Linux). Even with permission 777, Linux only allows the file owner to change permissions.

donquixote’s picture

Status: Needs work » Needs review
StatusFileSize
new316 bytes

Let's try a different approach.

Unsetting the 'gmap_marker_file' variable on flush cache will cause the markers to be rebuilt next time they are needed, but not immediately.
Most likely, this "next time they are needed" will be from a web user.

Testing instructions:

Preparation:
- Make sure that everything in sites/default/files is owned by web user, e.g. www-data.

Testing steps, in random order:
- Run drush cc all on cli
- Flush caches via the UI, in random order.
- Visit a page with a gmap.
- Regenerate marker cache on admin/config/services/gmap.
- Delete the file sites/default/files/js/gmap_markers.js, and try the above again.
- Delete the directory sites/default/files/js, and try the above again.

liam morland’s picture

Perhaps it should delete the file as well.

rblau06’s picture

Applying the patch and following the steps in #35 worked for me - thank you!

cprofessionals’s picture

Confirmed #35 worked here as well.

crutch’s picture

+1 #35 - Thanks

ikeigenwijs’s picture

#35 ++ seems to work

jmev’s picture

I applied patch #35 and also set perms to 777 for the sites/default/files directory and that helped. Thanks, donquixote for all your work.

solideogloria’s picture

Status: Needs review » Reviewed & tested by the community

  • podarok committed af61c04 on 3.0.x
    Issue #2693297 by donquixote, jackalope, betz: GMap is unable to save...
podarok’s picture

Version: 7.x-2.x-dev » 3.0.x-dev
Status: Reviewed & tested by the community » Fixed

thnx, merged #35

the_g_bomb’s picture

Status: Fixed » Needs work

I don't think the correct patch was commited unfortunately.

The patch commited does not fix the issue, it's just a workaround to stop the markers being regenerated during a cache clear. Now, I suspect, the only way to regenerate the markers is to log into the site and go to admin/config/services/gmap.

This patch also just deletes the gmap_marker_file variable, but leaves the file in place, so it's not even a full solution IMHO.

I think this should remain in needs work until the issue of markers being able to be regenerated by cron, drush and also through the UI is fixed.

the_g_bomb’s picture

Status: Needs work » Needs review

I think Neograph734 had it early on, but it doesn't look like a patch was ever produced.
https://www.drupal.org/project/gmap/issues/2693297#comment-11009209
The check for the directory has been failing before the file was attempted to be saved. I think while the trailing slash should have been trimmed, it doesn't look like it was before the check was made.

  • podarok committed af61c04 on 7.x-2.x
    Issue #2693297 by donquixote, jackalope, betz: GMap is unable to save...
podarok’s picture

Version: 3.0.x-dev » 3.0.3
Status: Needs review » Fixed
the_g_bomb’s picture

Hi, could this be backported to 7.x-2.x as well please?

Status: Fixed » Closed (fixed)

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

frodri’s picture

Version: 3.0.3 » 7.x-2.x-dev
StatusFileSize
new1.07 KB