I never used Drupal on windows before but now I just wanted to test my module on clean drupal and found out that I just cant use

drupal_add_js(MY_MODULE_ROOT_REL. '\\js\\somejs.js'); 

// or

drupal_add_js(MY_MODULE_ROOT_REL. '/js/somejs.js');

I defined my custom constants as

/**
 * Define root constant. (An absolute path: /home/var/www/)
 * This is used to prevent using drupal_get_path() cause __DIR__ is much faster and
 * don't use database connection to find out there this module is located.
 * @note requires PHP 5.3+
 */
define('MY_MODULE_ROOT', __DIR__);

/**
 * Relative path to this module (sites/default/....)
 */
define('MY_MODULE_ROOT_REL', str_replace(DRUPAL_ROOT. DIRECTORY_SEPARATOR, '', MY_MODULE_ROOT));

Disclaimer:
I know that Windows is not platform for develop but I think it is not good if Drupal won't work on windows too.
I know about drupal_get_path() but I don't want to use database connection just to find out the path to my module (I use drupal bootstrap_database layer and only include constant.inc files)

Comments

cadila’s picture

cadila’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: 2447301-drupal-encode-path-windows-fix-01.patch, failed testing.

cadila’s picture

StatusFileSize
new344 bytes
cadila’s picture

Issue summary: View changes
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: 2447301-drupal-encode-path-windows-fix-02.patch, failed testing.

cadila’s picture

Issue summary: View changes
cadila’s picture

StatusFileSize
new403 bytes

Fixed patch cause it was in wrong format

cadila’s picture

Status: Needs work » Needs review
cadila’s picture

Category: Feature request » Bug report
mgifford’s picture

Version: 7.34 » 7.x-dev
Issue tags: +needs review on Windows

This should get reviewed on a windows machine. Does it matter if it is IIS or Apache?

cadila’s picture

no it doesn't. I guess it without patch we will fail on both servers. Without patch we only can get it work with Denwer distribution which can simulate Linux paths (it creates virtual disks). I tested on xampp.

mgifford’s picture

Version: 7.x-dev » 8.0.x-dev

I think we have to add this functionality in Drupal 8, even though drupal_encode_path() was removed here #2221695: Remove uses of deprecated URL functions since it was replaced with https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!UrlH...

mgifford’s picture

cadila’s picture

Great idea to port this to D8 but actually I'm not familiar with D8 so can't test. Need someone to test latest patch for d8

mgifford’s picture

Re-uploading patch for the bots.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Title: drupal_encode_path doesn't support Windows paths » UrlHelper::encodePath() doesn't support Windows paths
Version: 8.9.x-dev » 9.2.x-dev
Status: Needs review » Needs work
Issue tags: -drupal_encode_path, -windows paths, -needs review on Windows +Windows, +Needs reroll, +Needs issue summary update, +Bug Smash Initiative, +Needs tests

The use case in the original report is no longer valid (we use library definitions instead of direct references to js/css files). However the bug report itself might be.

ankithashetty’s picture

Issue tags: -Needs reroll
StatusFileSize
new530 bytes
new468 bytes

Just updated patch in #16 to fix custom command failures, thanks!

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kim.pepper’s picture

Status: Needs work » Postponed (maintainer needs more info)

Reviewing as part of Bug Smash Initiative. As per the comment in #25 marking this as PMNMI.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there's been no follow up going to close this one out. If still a bug in D11 please re-open.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.