Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have encountered a new issue in statistics.php file.
My statistics counters do not increment. I am running on IIS and the define at the top
define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php')));
is not platform directory separator aware.
It should be something like:
PHP_OS == "Windows" || PHP_OS == "WINNT" ?
define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '\\modules\\statistics\\statistics.php'))) :
define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php')))
Comment | File | Size | Author |
---|---|---|---|
#3 | 2327953-ajax-stats-not-working-IIS.patch | 667 bytes | david_garcia |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedThere's a patch from @david_garcia based on an idea from @mikeytown2 at #1209532-247: Count node views via AJAX in the statistics module that fixes this in a way that shouldn't involve checking the operating system - let's review that.
Comment #2
fgmWhy not use the standard DIRECTORY_SEPARATOR constant instead of doing manual replacements with '/' and '\\' like this ?
Comment #3
david_garcia CreditAttribution: david_garcia commentedComment #4
david_garcia CreditAttribution: david_garcia commented@fgm Yes we could use the DIRECTORY_SEPARATOR, but we need a new patch then.
Comment #5
Timothy.Siford CreditAttribution: Timothy.Siford as a volunteer commented+1. Tested on Drupal 7.39, IIS, SQL Server 2014, PHP 5.6.0.
Comment #6
cilefen CreditAttribution: cilefen commentedThis needs work for #4 or a decision not to go with DIRECTORY_SEPARATOR.
Comment #7
david_garcia CreditAttribution: david_garcia commentedAssuming that you don't know what the input will be like, this is much more robust, because it normalizes whatever results from calling realpath($_SERVER['SCRIPT_FILENAME']).
So I vote that we go with the current no brain melter patch unchanged.
Comment #8
vanessakovalsky CreditAttribution: vanessakovalsky as a volunteer commentedNeed to check and use constant DIRECTORY_SEPARATOR in statistics.php file
Comment #9
vanessakovalsky CreditAttribution: vanessakovalsky as a volunteer commentedStill need to fix on D10 on statistics.php line "chdir("../../..")