Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-21 07:50:46

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Is DS really needed?

Looking through some of TXP’s code, DS is used rather inconsistently. For example, txp_plugin.php uses forward slashes for all the includes. Given TXP’s been running on IIS servers, is DS really needed? It seems like as long as absolute paths are provided, PHP converts forward slashes to backslashes. Otherwise, the plugin tab wouldn’t be working for Windows-folk.

Offline

#2 2008-06-21 08:30:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Is DS really needed?

fwiw I didn’t use it, then was told it was a good idea so I switched, but I think that ended up causing problems on some local installs so I have reverted to using a plain old / and letting PHP do the work. Rightly or wrongly.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2008-06-21 08:51:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Is DS really needed?

For URLs the forward slash should be used, regardless of OS.
For file paths using DS is better in cases where there’s a risk of having paths with mixed forward/backslash like /programdata/textpattern\files. When slashes are used consistently (either forward slash or backslash, not both within one path), I don’t think DS is needed.

Offline

#4 2008-06-21 10:44:57

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Is DS really needed?

AFAIK you must use DS for all file path parsing.

Apart from the issue of code consistency; it doesn’t matter for strings you give the OS (like the ones JM mentioned in txp_plugin.php) the OS can cope with both.

However, it will matter when it comes to doing anything with a path the OS gives to you. Imagine you assume that a Unix (‘/’) directory delimiter is used. Then your code splits a path you get from your OS based on that assumption. That’s ok on Unix but your code fails to split the path as expected when it’s running on a windows server (‘\’) instead of Unix.

You then get support calls from the folks using your code/plugins — not fun — especially when you can’t reproduce the problem on your Unix box.


Steve

Offline

#5 2008-06-21 10:50:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Is DS really needed?

Ahhh, makes sense. I’ll be more mindful of which direction the communication path is going when I do directory stuff in future, thanks for the advice.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2008-06-21 11:46:53

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Is DS really needed?

Thanks Steve – we need to wiki that info :).

Offline

Board footer

Powered by FluxBB