Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2009-07-03 23:17:55

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Specify article_custom limit AND check for non-empty custom field?

OMG, jsoo, you just started a whole new Txp era! Thank you :)

Offline

#22 2009-07-04 00:09:33

artagesw
Developer
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Tread carefully there. That is likely an “unintended feature” that happens to work now but could break in the future. For one thing, it is MySQL-specific, which is something to watch out for if you want to maintain the flexibility of changing to a different database backend in the future.

Offline

#23 2009-07-04 00:20:20

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Yes, some words from wet about this “unintented feature” could be helpful to know if it’s safe to use it in the long run.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#24 2009-07-04 00:35:04

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Specify article_custom limit AND check for non-empty custom field?

From a quick survey the same pattern (and the operator LIKE) will also work in SQLite and PostgreSQL.

Edit: And I wouldn’t call it “unintended”. It was certainly intended by whoever chose to use LIKE instead of =, as shown by the following comment in the function in question (buildCustomSql() in publish.php):

# nb - use 'like' here to allow substring matches

Last edited by jsoo (2009-07-04 01:52:15)


Code is topiary

Offline

#25 2009-07-04 03:16:40

artagesw
Developer
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

LIKE and the “%” and “_” characters are standard SQL, but not always consistently implemented. Also, the assumption that the semantics of a tag attribute are equal to the semantics of SQL is not necessarily a good one. It can make for fragile code. Tags serve as an intermediary between you and the storage engine (database) for a reason. Pierce that veil at your own risk. ;)

Offline

#26 2009-07-04 11:57:06

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Specify article_custom limit AND check for non-empty custom field?

There’s also sort. Used to be split into sortby and sortdir attributes; now we’re expected to put valid ORDER BY expressions into sort. Having separate attributes is, I think, closer to your idea of tags as intermediary. Which I agree with, but I also agree with keeping the number of attributes in check. Something’s gotta give.

And there’s smd_query. Probably lots of MySQL-specific Txp code out there now. Again, I’m not saying this is good in itself, but by gum it works. Undoubtedly some of us will have some extra work, some day, prepping an existing site for conversion to a different DB engine. But probably not much. The smd_where_used plugin will be a handy helper for that task…


Code is topiary

Offline

#27 2009-07-04 17:10:56

artagesw
Developer
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

jsoo wrote:

There’s also sort. Used to be split into sortby and sortdir attributes; now we’re expected to put valid ORDER BY expressions into sort.

Yeah, there do seem to be a few instances where database dependency has crept into core. Not a good thing IMHO.

And there’s smd_query. Probably lots of MySQL-specific Txp code out there now.

Sure, but that’s a plugin, and plugins are by definition a compatibility risk. I’m more concerned with the core and being able to move it forward effectively without breaking existing sites.

Offline

#28 2009-07-05 02:09:12

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,530
Website

Re: Specify article_custom limit AND check for non-empty custom field?

artagesw wrote:

Yeah, there do seem to be a few instances where database dependency has crept into core. Not a good thing IMHO.

Oh, yeah, conditionals or a parser for the values, which IMHO makes it more limited and slower.

artagesw wrote:

plugins are by definition a compatibility risk.

Lol’d.

Offline

#29 2009-07-05 03:20:12

artagesw
Developer
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Gocom wrote:

Oh, yeah, conditionals or a parser for the values, which IMHO makes it more limited and slower.

By that argument, you might as well throw away the entire Textpattern tagging system and write straight PHP for your templates. Compared with PHP, Textpattern tags are slow (require an additional layer of parsing) and limited. But there are benefits to tags that outweigh these costs, so we trade off some performance and flexibility to gain these benefits.

artagesw wrote:

plugins are by definition a compatibility risk.

Gocom wrote:

Lol’d.

It’s true. Plugins are essential, yes. But when you decide to use them, you must be prepared for potential problems down the road. From Textbook:

When a webmaster uses a plugin to achieve a goal on its website, if that goal is “critical” then he should seriously think it through. Because if:

  • a new Textpattern version breaks the plugin
  • the plugin is not maintained anymore
  • a security flaw is discovered with it

and the plugin author does not (or can’t) fix it, the site may not function as you intend.

Offline

#30 2009-07-05 03:44:09

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,530
Website

Re: Specify article_custom limit AND check for non-empty custom field?

artagesw wrote:

gain these benefits.

But we need to weight the benefits. And IMHO, I wouldn’t put that little sort value in the category of benefits. Also it will disable MySQL version destricted hacks, that for examle right now make some websites work. For example sorting of varchar fields as ints.

artagesw wrote:

It’s true. Plugins are essential, yes. But when you decide to use them, you must be prepared for potential problems down the road.

I just lol’d for your definition, chill out :). I know that, or then I’m been on drugs donuts for the last five years. Donuts…

Offline

Board footer

Powered by FluxBB