Site not working after Google maps API key update

Permalink
Hello, I was working on a brand new 8.1 install, using the base theme Elemental, and I was cruising right along, updated the google maps with a new address, put in the API key, validated it, and then the site froze, and it will not work again, giving me a ERR_TOO_MANY_REDIRECTS

http://www.somervilleservices.com/...

Any ideas? I know very little about coding itself, but would be willing to give it a go if some one could guide me.

Thanks!

 
mnakalay replied on at Permalink Reply
mnakalay
Hello,

If you are absolutely certain the problem started when you added the API Key and everything else was working before, you could disable the code that uses that key and see if it restores your site.

If it does, you will then be able to remove the google maps block and re-enable the code.

You should look on your server where your site's files are. First you have to determine if the website was updated.

Look inside the "updates" folder and if there are files and folders there, go inside the folder with the highest version number (for instance 8.1.0) and find the folder labelled "concrete"

inside concrete look for the folder "blocks" and then inside it the folder "google_map"

Inside google_map you need to modify 2 files:
controller.php
Look for a function like this
public function registerViewAssets($outputContent = '')
    {
        $this->requireAsset('javascript', 'jquery');
        $c = Page::getCurrentPage();
        if (!$c->isEditMode()) {
            $this->addFooterItem(
                '<script defer src="https://maps.googleapis.com/maps/api/js?key='
                . Config::get('app.api_keys.google.maps')
                .'"></script>'
            );
        }
    }

and comment it out, meaning put slash and star (/*) just before and a star and slash (*/) just after so it looks like this:
/*
public function registerViewAssets($outputContent = '')
    {
        $this->requireAsset('javascript', 'jquery');
        $c = Page::getCurrentPage();
        if (!$c->isEditMode()) {
            $this->addFooterItem(
                '<script defer src="https://maps.googleapis.com/maps/api/js?key='
                . Config::get('app.api_keys.google.maps')
                .'"></script>'
            );
        }
    }
*/


Now you can save and close that file and go to the next file.

View.php
in that file, the last bit of code is
<script type="text/javascript">
    function googleMapInit<?php echo $unique_identifier?>() {
        try{
            var latlng = new google.maps.LatLng(<?php echo $latitude?>, <?php echo $longitude?>);
            var mapOptions = {
                zoom: <?php echo $zoom?>,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                streetViewControl: false,
                scrollwheel: <?php echo !!$scrollwheel ? "true" : "false"?>,
                draggable: <?php echo !!$scrollwheel ? "true" : "false"?>,
                mapTypeControl: false
            };
            var map = new google.maps.Map(document.getElementById('googleMapCanvas<?php echo $unique_identifier?>'), mapOptions);
            var marker = new google.maps.Marker({

Again you need to deactivate this code but this time the symbols used are different. You should start with <!-- and end with --> so you code now looks like
<!--
<script type="text/javascript">
    function googleMapInit<?php echo $unique_identifier?>() {
        try{
            var latlng = new google.maps.LatLng(<?php echo $latitude?>, <?php echo $longitude?>);
            var mapOptions = {
                zoom: <?php echo $zoom?>,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                streetViewControl: false,
                scrollwheel: <?php echo !!$scrollwheel ? "true" : "false"?>,
                draggable: <?php echo !!$scrollwheel ? "true" : "false"?>,
                mapTypeControl: false
            };
            var map = new google.maps.Map(document.getElementById('googleMapCanvas<?php echo $unique_identifier?>'), mapOptions);


Now save your code and reload your site.

2 things might happen:
1- your site loads normally meaning you were right, the API Key was the problem.
Go to the page you put the map on, put it in edit mode and remove the map then save your page.

2- the site still doesn't load and the API key is not the problem.

In any case, whether it works and you removed the map or it doesn't work, you should remove your modifications from the files so they go back to normal.

Good luck and I hope it helps
ankah replied on at Permalink Reply
Thanks for the help!

That did not do it, and I am out of ideas as to what caused it, since validating the API key and saving the page was the last thing I did before getting locked out.

At this point I think will probably remove the existing installation and start over, but I will take a peek at ERR_TOO_MANY_REDIRECTS issues before hand.
mnakalay replied on at Permalink Reply
mnakalay
When I try to load your site, it keeps loading until it times out but it never showed me that error ERR_TOO_MANY_REDIRECTS

What you could do is have a look at your PHP error log file. You'll probably have more meaningful information concerning which file is responsible for the problem.

You can probably have access to it from your cPanel or ask your hosting company.

If you need help reading it, you can send it to me by PM if you want but I suggest you don't post it here as this is a public forum and there might be information in the error log you don't want to make public.
ankah replied on at Permalink Reply
Depending on what time you tried, I may have been in the process of reinstalling Concrete5.

In general I am starting to grow frustrated with it, because I keep running into issues while doing what I thought were simple things, like editing a block via the edit this page function or changing a thumbnail picture via dashboards --> settings --> header nav/attributes.

I do not code, so these problems are manifesting while attempting to change/edit things via the regular interfaces/blocks/tools. I have some experience with Concrete5, and this is my second site with it, but it seems to be leaning more towards developers now, than end users. Is this the direction (just curious)?

Anyhow, I can not log in, or do anything. I am back to having the ERR_TOO_MANY_REDIRECTS display atwww.www.somervilleservices.com.... I will be happy to share any logs, since there really isn't anything on that site that matters, only a couple of hours worth of basic editing (headers, footers, etc). I would like not only to retrieve what I have done so far, but most importantly, I would like to avoid issues moving forward.
ankah replied on at Permalink Reply
Here is the last error to be logged, which is being repeated quite a few times:

[23-Mar-2017 20:03:50 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 22652 bytes) in /home/somervil/somervilleservices.com/concrete/vendor/imagine/imagine/lib/Imagine/Gd/Image.php on line 602
ankah replied on at Permalink Reply
I investigated the error message from the log and found this:

https://www.concrete5.org/marketplace/addons/mainio-sync/faq-possibl...

There are others examples of the memory issue. So I did get into the php.ini file, as suggested on a legacy thread, and it did the trick, so the issue was not with Concrete5 per se, but my high resolution images and maybe the server. What gets me is how the memory was set at 256, which I would imagine would be enough to handle the 11 pictures I was uploading, considering how the largest was 7.8.

Is there an add on that could "cap" total memory requests from images? I am still a little perplexed as to why this issue took place.
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi ankah,

A 7.8MB image is quite large and will use substantial memory to process. It is not recommended to upload uncompressed, unresized images, especially with shared web hosting.

There is an Image Uploading feature you can try:
"Control maximum dimensions for all images uploaded to your website. Ensures that enormous images will be resized."
Dashboard > System & Settings > Files > Image Uploading
ankah replied on at Permalink Reply
Thanks! Very helpful info.

Had I started with that, I would have saved myself some time. Learned a lot today.
mnakalay replied on at Permalink Reply
mnakalay
@MrKDilkington you beat me to it :)