Skip to content

Changes In Textile v2.5

netcarver edited this page Dec 12, 2012 · 2 revisions

The v2.5 release has some major changes to the codebase and a few minor additions to its abilities to handle text. The changes outlined here are now committed to the 2.5 & master branches of netcaver/textile. Here is a summary of what changed over the pre v2.5 code.

To facilitate textile’s uptake in other projects & to make it plain easier to read, I moved the code towards PSR-2 compatibility. I have adopted PSR-2 for textile because…

  • textile has used no coding standard to date and has had many contributors who have used different styles. The code reflects this and it needed some sanity restored to it.
  • It gives people who may contribute a standard to work to.
  • I was advised that a minimum of PSR-1 compatibility was required for textile’s uptake in at least one other CMS.

If you are still using pre 2.5 code here is a run-down of what could bite you while migrating to v2.5 or above.

Are you overriding textile’s ‘txt_’ defines to customize something?

If you are using pre 2.5 textile in exactly its default configuration with respect to its ‘txt_’ defines there is nothing to worry about so skip down to the next heading. If not, this applies to you…

As PSR-1 (needed for PSR-2) doesn’t seem to like code declarations & side effects (such as the ‘txt_’ defines) in the same file, removed all the ‘txt_’ defines listed here. If you are using them, you will need to start calling setSymbol('name', 'value') prior to calling textileThis() or textileRestricted(). NB. the ‘name’ to pass into setSymbol() is as shown in the link above without the leading ‘txt_’ (which is no longer needed as the names will no longer be in global scope.)

Using a define called ‘hu’ to prefix relative image paths?

If your project doesn’t use any define called ‘hu’ then skip to the next heading, else read on…

Textpattern CMS uses a define called ‘hu’ to point to its root path and if pre 2.4 textile found a define called ‘hu’ it would use that to prefix all root-relative image paths. Now that textile is breaking free from its Textpattern CMS roots I took the time to break this hidden coupling between the two and instead replace it with a generic, and explicit, setRelativeImagePrefix() method. This allows other projects to use relative image path prefixing if they need to without using the ‘hu’ define and without the possibility of a name conflict if they already happen to use a define called ‘hu’ for something else.

Still using PHP4?

I thought not, but I have to cover this anyway; next is PSR-2’s requirement for explicit visibility on all properties and methods. As textile comes from a PHP4 heritage it has never had these; everything is public — even the things that shouldn’t be. Most methods and properties are now protected or private. So, even if you are running PHP5+, this change to textile will bite if…

  • you are calling any methods other than the constructor, textileThis() and textileRestricted().
  • you are accessing any of the class properties — none of these are now public.

If you want v2.5 or above, you will need to stop calling the internal properties & methods of Textile.