Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.1 - custom Date Range issue #51

Closed
ctseo opened this issue May 12, 2017 · 43 comments
Closed

2.5.1 - custom Date Range issue #51

ctseo opened this issue May 12, 2017 · 43 comments
Assignees

Comments

@ctseo
Copy link

ctseo commented May 12, 2017

Hello,

On your latest version 2.5,1, i can't chose date range and on reporting page... to change Report Settings arrow doen't work, to change something on settings.
Error 1: http://prntscr.com/f6ygoo
Error 2: http://prntscr.com/f6ygaw
http://prntscr.com/f6yhlu

@PromInc
Copy link
Owner

PromInc commented May 13, 2017

I'm unable to recreate this issue on my end. Have you made any customizations to your code?

One thing I'm confused by is in http://prnt.sc/f6ygoo. You have Specific Dates selected, but I don't see the date selectors expanded. When that radio button is selected there should be two calendar displays for picking the to and from dates. This makes me think that the file /organic-search-analytics/js/lib/jquery/jquery-ui.1.11.4.custom.min.js isn't loading?

Those are my initial reactions.

@nepohex
Copy link

nepohex commented May 13, 2017

I have the same issue, and didn't change anything. It was like this "from box" , tried Firefox and Chrome but still doesnt work. I thought you know about it and fix it later.

PromInc pushed a commit that referenced this issue May 18, 2017
Bug fixes and layout/style updates for the report chart/graphs.

Addresses #51
@PromInc
Copy link
Owner

PromInc commented May 18, 2017

This is not a known issue. I did a clean install of version 2.5.1 from Github and can not recreate this issue. Well sort of... I was able to to see a similar issue but it didn't 100% match up with the screenshots.

I've done a bit of work on updating how the charts function - I feel that I have the bugs worked out of it now in version 2.5.3 Please download this version from the current master branch (not created into a release) and see if this resolves your issues. Please report back here with your findings so I know if there is more work that needs to be done.

If there are issues, it would be helpful to know more about what scenarios create it:

  • What is your webserver/hosting environment like? (Windows with XAMPP, Linux, 3rd party, other?)
  • Did you upgrade from a prior version? What version was it?
    • If so, did you run the upgrade scripts (found on the home page)?
  • What report settings are needed to recreate this issue?
    • Does it happen on every report or only if certain criteria are applied?
  • Are there any special characters in the results returned on the page (query or page reports)

Let me know if version 2.5.3 works for you.

@nekromoff
Copy link

I can not change this either, only via URL directly

@nekromoff
Copy link

I have now upgraded to the 2.5.3 version and the bug is still there.
Once I click in the reports on "Specific dates", no fields for date selection are shown.

@PromInc
Copy link
Owner

PromInc commented May 22, 2017

@nekromoff There must be a javascript error being thrown - possibly due to a library file not loading? jQuery, jQuery UI libraries, etc.

Please press F12 to open the developer console, click the Console tab, reload the page, click the Specific Dates radio button, and then provide a screenshot showing what is in the console tab of the developer window. That will help me to understand what is failing and/or not loading.

@nekromoff
Copy link

SyntaxError: unterminated string literal[Learn More] report.php:467:25

@nekromoff
Copy link

seems to be a problem in this function:

		<script type="text/javascript">
				$.get('https://api.github.com/repos/prominc/organic-search-analytics/releases/latest', function (data) {
					var latestVersion = data.tag_name;
					if( latestVersion > '2.4.3
' ) {
						$('#upgradeVersion a').attr('href', data.zipball_url);
						$('#upgradeVersion a span#upgradeVersionNumber').text(latestVersion);
						$('#upgradeVersion').show();
					}
				});
				</script>

@PromInc
Copy link
Owner

PromInc commented May 22, 2017

The first thing that stands out to me is that you are not using the latest version - that shows that you are currently on version 2.4.3 - the current is 2.5.3 (as you stated you are using).

I'd suggest ensuring your entire repository is up to date.

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

Also a bug fix to this script was added in version 2.5.0.

The version number you see in the script you pasted comes from a text file. The text file had a line break (as you can see in your pasted code), and then the javascript had issues with comprehending that text. Version 2.5.0 removed the line break as well as added a trim that would remove whitespace such as line breaks.

Can you please update your codebase and report back if that clears up the issue?

@ctseo
Copy link
Author

ctseo commented May 23, 2017

When you select custom range, it don't display the calendars. You can see on this printscreen : http://prntscr.com/fb1cha

@PromInc
Copy link
Owner

PromInc commented May 23, 2017 via email

@ctseo
Copy link
Author

ctseo commented May 23, 2017

Hello.
It's not a cache problem. I used incognito too... and same problem.

report.js file: http://prntscr.com/fb1ztk

I have the latest version... 2.5.3. I replaced all files from 2,.5.3 zip from my gsc2 folder.

@PromInc
Copy link
Owner

PromInc commented May 23, 2017 via email

@nekromoff
Copy link

I have done git pull, but still see the same bug and same version that you said is from the previous file.

@nekromoff
Copy link

OK, you might have changed the directory structure between the versions, so now the organic-search-analytics folder is duplicated in the former organic-search-analytics folder with the new version.

Once this has been fixed, the new version works.

@ctseo
Copy link
Author

ctseo commented May 23, 2017

Yes PromInc, you are right! I don't have this function updateDateRange() : http://prntscr.com/fb39gq

I tried only update or daterange ... nothing.

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@nekromoff - it sounds like you may have found the root issue? If I'm following you correctly, in the root directory you are finding files - report.php, index.php, etc. You'll notice those files are no longer a part of this repository - they have been moved into this directory organic-search-analytics. The design behind this structure is that the files at the root of the directory are used for setting up your project and information and really are not necessary to keep long term. The actual codebase all lives in the organic-search-analytics directory.

When doing updates to your repository it could be done via a git pull (either command line or the desktop utility) or by manually downloading the zip file and updating your local copy of the code. Using a git pull it will delete and move files as needed, where as using the zip download you are in charge of maintaining the file system. It's probably best to delete all files and replace them if you are using the .zip file method WITH EXCEPTION of the config directory and log directory - those are specific to your installation.

@nekromoff - Can you please confirm that this issue is no longer an issue for you?

@ctseo and @nepohex - Please look through your codebase on your local machines and ensure that the files and file structure match that of the repository as it appears you may have the same issue as @nekromoff identified - accessing the project through an old set of code that is not longer supported.

@nekromoff
Copy link

nekromoff commented May 23, 2017

I have the whole project in /gsc
(that replaces organic-search-analytics folder)
once in gsc/ the structure is as follows:

ajax.php
apis
config
css
data-capture.php
data-capture-run.php
data-delete.php
fonts
inc
index.php
js
log
report.php
robots.txt
settings-configure.php
settings.php
upgrade.php
version.txt

that seems to be correct.

Anyway, there are the other two bugs #56 and #57 that I have encountered after downloading as ZIP.

I am not sure why the former (abandoned) files where not removed by git pull.

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@nekromoff did you run the upgrade scripts? You should have to run 2 upgrade scripts since you came from 2.4.3 to 2.5.3. In your web browser, click the Home button, then the text link Upgrade Scripts.

Make sure you run the scripts in order as well - clicking the following buttons:

  • Run Update for Version 2.x.x to 2.5.0
  • Run Update for Version 2.5.0 to 2.5.1

Follow any other instructions there as well, but this will update your database.

@ctseo
Copy link
Author

ctseo commented May 23, 2017

Nope. It didn't work for me. All files from zip seems to be ok. I tried to delete all except config & log directory and replace with the new version and i have same problem. Can be this problem because i have a lot of data in mysql, and calendar it freeze when try to get data ?

@nekromoff
Copy link

nekromoff commented May 23, 2017 via email

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@ctseo No the amount of data isn't the issue. According to your screenshots it is a javascript error.

  • What is your webserver setup like? It looks like it's on your local machine? What type of operating system? Are you using XAMPP, MAMP, USB WebServer, other?
  • Does this issue happen on the initial report page with no criteria set and no data returned or is this just happening after you have ran a report and data has been returned?

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@nekromoff when you downloaded as a zip file, did you set all of the configuration settings (database, etc.) or copy a copy of the config/config.php file into the newly setup project? Without setting those settings or using an existing copy of a config.php file the project doesn't know how to connect to the database, which is where the report settings are saved.

@ctseo
Copy link
Author

ctseo commented May 23, 2017

I have a older version, 2.3.1 where seems to work. I will try to update to 2.4 to see there is the problem.

@nekromoff
Copy link

nekromoff commented May 23, 2017 via email

@ctseo
Copy link
Author

ctseo commented May 23, 2017

@PromInc from branch: report-chart-updates it's not working. :) I had 2.4x version and works well.. when going to upgrade.. it's broken.

@ctseo
Copy link
Author

ctseo commented May 23, 2017

@PromInc : maybe it help you, you can see the printscreen: http://prntscr.com/fb5jvy
I removed the display none from css ( from inspect element ) and when i tried to select the date ... i saw this errors :)

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@ctseo Can you right click on the page and choose View Page Source. Scroll to the very bottom of the page and provide a screenshot of that? I'm wondering if you are getting a PHP error and the page isn't completely rendering. The javascript file that's missing is loaded at the bottom of the page.

Can you please provide me information on your webserver setup as asked prior?

@ctseo
Copy link
Author

ctseo commented May 23, 2017

@PromInc : I don't see any php errors. I use xamp v3.2.1

Screenshot: http://prntscr.com/fb5s8p

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@ctseo Does the end of the source code look something like this?

<script type="text/javascript" src="js/report.js"></script>
<footer>
<div class="floatleft">
Developed by <a href="http://www.promincproductions.com/blog" target="_blank">Brian Prom</a>
</div>
<div id="versionBlock" class="floatright">
<span>ver 2.5.1</span>
<span id="upgradeVersion" class="floatright" style="display:none;">A newer version is available. <a>Download <span id="upgradeVersionNumber"></span> now!</a></span>
<script type="text/javascript">
				$.get('https://api.github.com/repos/prominc/organic-search-analytics/releases/latest', function (data) {
					var latestVersion = data.tag_name;
					if( latestVersion > '2.5.1' ) {
						$('#upgradeVersion a').attr('href', data.zipball_url);
						$('#upgradeVersion a span#upgradeVersionNumber').text(latestVersion);
						$('#upgradeVersion').show();
					}
				});
				</script>
</div>
<div class="clear"></div>
</footer>
</body>
</html>

The two most notable lines here are these:
<script type="text/javascript" src="js/report.js"></script>
and
</html>

These tell me that the end of the page is loading as desired and the request to load the js/report.js file is being made. Your prior screenshots show that this request isn't being made - not sure why that would be.

This is the other reason I asked for a screenshot - a picture says 1,000 lines of code. :)

@nekromoff
Copy link

nekromoff commented May 23, 2017 via email

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

@nekromoff you're stumping me...

  • I can't find in the history of the project any time that <script type="text/javascript" src="js/script.js"></script> was loaded in the head of the page. It's always been at the bottom of the page since it was added in version 2.3.0.
  • I don't see a closing </html> tag in your sample your provided - does that not exist on your page?

@nekromoff
Copy link

nekromoff commented May 23, 2017 via email

@nekromoff
Copy link

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

Thank you @nekromoff - my apologies I miss-read one of your prior posts. script.js is in the head (that's good).

So you don't see <script type="text/javascript" src="js/report.js"></script> in the source code at all? That means that PHP doesn't think this is the report page... That means this is failing for some reason:

Ok, who here feels brave and wants to modify a file to test a possible solution? :)

https://github.com/PromInc/organic-search-analytics/blob/master/organic-search-analytics/inc/html/_foot.php#L3
Change:
<?php if( isset( $GLOBALS['scriptName'] ) ) { ?>
To:
<?php if( isset( $_SERVER['script_name'] ) ) { ?>

https://github.com/PromInc/organic-search-analytics/blob/master/organic-search-analytics/inc/html/_foot.php#L4
Change:
<?php if( $GLOBALS['scriptName'] == "report.php" ) { ?>
To:
<?php if( $_SERVER['script_name'] == "report.php" ) { ?>

@nekromoff
Copy link

nekromoff commented May 23, 2017

OK, it's pretty clear now why the report.js is not included:

You are incorrectly using $GLOBALS['scriptName']:
<?php if( $GLOBALS['scriptName'] == "report.php" ) { ?>

checking output of:
<?php print_r($GLOBALS['scriptName']); ?>
and it prints out:
/int/gsc/report.php (including the path)

instead you should change it to:
<?php if(stripos($GLOBALS['scriptName'],'report.php')!==FALSE ) { ?>

Once this is changed, your script works fine!

@PromInc
Copy link
Owner

PromInc commented May 23, 2017

I think the bigger issue is that I shouldn't be using $GLOBALS and instead $_SERVER['script_name']. I feel the later is the more universal solution for any/all server environments.

@nekromoff
Copy link

I agree with that, too 👍

@ctseo
Copy link
Author

ctseo commented May 24, 2017

@PromInc : Ok .. so the solution is:
Change on inc\html_foot.php
Change this: <?php if( $GLOBALS['scriptName'] == "report.php" ) { ?>
With this: <?php if(stripos($GLOBALS['scriptName'],'report.php')!==FALSE ) { ?>
And now it's working.

PromInc added a commit that referenced this issue May 24, 2017
Revert code that was proposed in #31, ported to #38, and mistakenly deployed via 9d72b4d that attempts to work with an Apache alias environment.  The proposed code modified the $GLOBALS['basedirWebServer'] and $GLOBALS['appInstallDir'] variables, which resulted in unexpected values in $GLOBALS['scriptName'].  The final result of this code change is that under certain Apache configurations it was not possible to reliably use $GLOBALS['scriptName'] to detect what page was being rendered and thus conditional situations were failing.  The example brought up in #51 is that a javascript file was not being loaded on the reports.php page.
@PromInc
Copy link
Owner

PromInc commented May 24, 2017

I agree that <?php if(stripos($GLOBALS['scriptName'],'report.php')!==FALSE ) { ?> is a possible solution.

I'd prefer to use an alternate solution however and have created a branch for testing this solution. @nekromoff and @ctseo I'd appreciate it if you were able to test this solution before I merge it into the master branch. Please test branch Issue#51-report.js-not-loading.

Looking deeper at this issue, I see the root of the problem was a change that was not intended to be deployed yet was made in version 2.5.0. A request to modify some code to handle an Apache alias environment was made in #31 (and is now tracked under #38). This unintentionally was added in 9d72b4d which is causing the root of the issue. Admittedly I don't fully understand the Apache alias environment, it's need, and thus can't put my stamp of guarantee on the fact that this code was a safe choice to add (and it's proven to not be safe as written).

My reason for this as the solution vs what @nekromoff offered is that this is the true root of the issue and I see that $GLOBALS['scriptName'] is used elsewhere in the codebase. So additional patches would need to be implemented if this was the solution of choice.

It is my belief that this solution should also resolve #56 and #57.

@ctseo
Copy link
Author

ctseo commented May 24, 2017

@PromInc : it's working :)

@PromInc
Copy link
Owner

PromInc commented May 26, 2017

Thank you @ctseo

I have merged this fix into the master branch (as well as another bug fix for the reports if a query or page has a single quote in it).

I appreciate you all bringing up this issue and helping me to debug it. It only affects Apache servers which is not my primary hosting/testing environment.

@PromInc PromInc closed this as completed May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants