Pressflow does not create the $_SESSION variable for anonymous users, which produces this error on the /shorten page:

Notice: Undefined variable: _SESSION in shorten_form_shorten() (line 417 of /path/to/drupal/sites/all/modules/shorten/shorten.module).

Easy fix. Patch attached.

CommentFileSizeAuthor
pressflow-shorten.patch358 bytesshawn dearmond

Comments

icecreamyou’s picture

Title: Pressflow Compatibility » Use multi-step form structure for URL shortening form instead of $_SESSION
Category: bug » task
Priority: Normal » Major
Status: Needs review » Needs work

That patch will make it impossible for anonymous users to use the URL shortening form. (No shortened URL will appear for them.)

The real way to fix this (and the real reason this is a problem) is by changing the way the form itself is generated. The way it currently works is a hack: the most recent short URL is stored in a cookie and displayed the next time the form is generated. However there are two problems with this: (1) if the user stops the page from loading after the shortened URL has been generated but before the URL shortening form gets regenerated, then the shortened URL will show up the next time the URL shortening form is rendered, even though there is no indication on the form of what long URL it is related to; and (2) if the user submits two URL shortening forms at the same time (e.g. in different tabs) then the shortened URLs could get switched or one of them could get dropped.

The correct way to solve this problem is to use multi-step form structure, which would store the shortened URL in the form cache in the database. However multi-step forms are kind of a pain in D6 so I've never had the motivation to work on it. I've done multi-step forms before and even written a blog post on them, it's just not a fun process.

This is actually a significant problem in this module that has been around since I first added a UI. I've never bothered to fix it because I think of this module as an API first and foremost.

icecreamyou’s picture

Version: 6.x-1.9 » 6.x-1.x-dev
Priority: Major » Normal
Status: Needs work » Patch (to be ported)

This is fixed in the D7 branch... but multi-step forms and AJAX are a lot nicer in D7, and I don't know how difficult it will be to get them to play nicely together in D6.

icecreamyou’s picture

Priority: Normal » Major
Status: Patch (to be ported) » Fixed

Committed fix to D6 (dev). It turns out that the required changes are almost identical to D7.

Status: Fixed » Closed (fixed)
Issue tags: -$_SESSION, -Pressflow

Automatically closed -- issue fixed for 2 weeks with no activity.