I'm running Drupal 5.3 under Ubuntu (Gutsy Gibbon) on an Intel box with Apache 2.2.6, PHP 5.2.4, and Postgres 8.2.5. When I try to activate a freshly downloaded copy of the autopath 5.x-2.0 module, I get a blank screen and the following message in my Apache error log:
PHP Fatal error: Call to undefined function db_change_column() in /www/Drupal/sites/all/modules/pathauto/pathauto.install on line 58, referer: http://drupal/admin/build/modules
As this is a fresh testbed installation of Drupal with very little content, I replaced the autopath module with version 1.2, which installed with no problems. I'd prefer to be using the latest and greatest, if the above problem can be resolved.
Thanks.
Comments
Comment #1
gregglesThis is interesting. I've done several fresh installs and never had this problem. Can you confirm that the update.php file exists on your server? Perhaps you are just the first person on PostgreSQL who installed the 5.x-2.0 version?
That code was only added so that the module would work with custom node types that have reaaaaally long names. So...I've removed this temporarily from the -dev branch so that at least it will work for the majority of users.
According to http://www.postgresql.org/docs/7.4/interactive/sql-altertable.html
We need to do something like this to have the same effect on mysql when running under pgsql:
Perhaps you could test that on a test system? If so I'll add a note about how to do that to the README.txt or INSTALL.TXT for pgsql users
Comment #2
lylep commentedI confirmed that update.php does exist in the drupal base installation directory, and function "db_change_column" is indeed in that file. Permissions on update.php are fine (644).
I ran the database commands above on a test Postgres table, and they ran with no errors and successfully changed the table as expected.
Perhaps this is a php path problem?
Comment #3
HorsePunchKid commentedI just got the same error. Instead of the
db_change_columncall, I just changed it to:db_query("ALTER TABLE {variable} ALTER name TYPE varchar(128)");This worked fine against Postgres 8.2.4. No need to reiterate the
NOT NULLandDEFAULTclauses, since they're already there. I don't have a 7.4 to test on, but the docs make it look like this should work there, too.Comment #4
gregglesI don't have postgresql to test against, so if one of you could roll and test a patch that would be great.
Comment #5
HorsePunchKid commentedSame thing in patch form. I don't understand the error, but this fixes it.
Comment #6
gregglesHorsePunchKid - thanks. Did you test on 7.3/7.4? That reference page you pointed to doesn't show the use of this syntax as far as I can tell.
@lylep - could you test this latest patch? I generally like to have at least one extra tester besides the person who creates a patch (regardless of whether it's me or someone else...).
Comment #7
lylep commentedI'll check the patch on my installation and let you know. Unfortunately, I no longer have a pg 7.4 running on any of my servers, so can't help there. I do recall, however, that changing table structures in the older versions was not as straightforward.
Comment #8
lylep commentedThe good news: the patch to pathauto.install worked on my setup; the module activated with no errors and the aliases I had already entered using 1.2 were preserved.
The bad news: I confirmed that a column data type cannot be changed using this command in Postgres 7.x; see http://www.postgresql.org/docs/7.4/interactive/sql-altertable.html. Data types in the older versions can only be modified using the rename-old-column + create-new-column + copy data + delete-old-column approach that the unpatched version of pathauto.install was trying to do. The code in update.php appears to be correct, but for some reason pathauto.install is not finding the functions defined there. How are those normally expected to be included during a module activation process?
If the inclusion problem cannot be resolved, the alternative might be to patch pathauto.install to do the same 4-step column update directly.
Comment #9
gregglesAfter reviewing this patch more closely it seems wrong. The update_2 should work AFAIK - the problem is in pathauto_install, right?
@lylep - that function is only available in update.php which is only available when updating the schema - not installing it. Along those same lines - if you tested this on a system where Pathauto1.2 was installed then that doesn't test this problem because the code in question is never run.
For drupal 6 I believe the point is moot - the new schema system makes creation/maintenance of these tables much simpler.
So, we either have to copy the logic of db_change_column into pathauto.install OR we just ignore PostgreSQL7.x users. Thoughts?
Comment #10
lylep commented> After reviewing this patch more closely it seems wrong. The update_2 should work AFAIK - the problem
> is in pathauto_install, right?
Yep -- the original error message referenced pathauto.install as the source.
> Along those same lines - if you tested this on a system where Pathauto1.2
> was installed then that doesn't test this problem because the code in question is never run.
That's good to know. I wasn't sure if an upgrade to autopath was really the same as a fresh installation of that module. We are putting together a from-scratch Drupal on another server, and I can retry the 2.0 install there.
> So, we either have to copy the logic of db_change_column into pathauto.install OR we just ignore
> PostgreSQL7.x users. Thoughts?
I guess that depends on Drupal's philosophy on postgres support in general and how large of a user base that represents. Version 7.4 is still on the postgres Web page as available for download, so apparently they are still supporting it. Tweaking pathauto.install to add the four-step process will work with both 7.x and 8.x postgres, so that is probably the lowest impact solution -- easy for me to say, as I'm not the one making the patch. :)
Comment #11
gregglesThe reason I didn't like the idea of the longer command was that I was concerned that the Drupal user might not have the permissions to run all those commands. Then I read INSTALL.pgsql.txt which doesn't have _any_ mention of grants so maybe we don't need to worry about that :) Besides, the db_change_column does them all anyway...so maybe I'll just do that.
I'll try to make a patch soon so you can test it on your new install, lylep.
Comment #12
gregglesI think that the patch utility got confused when I applied it. Horsepunchkid's fix was in the right place, but not against the latest tip of the branch so my patch utility applied it wrong. Whoops.
Re-rolled to fix this and committed to DRUPAL-5--2
If someone can write the patch that will get it working with older versions of PostgreSQL that would be awesome. I've added this to the PgSQL queue of issues to review.
Comment #13
gregglesthis was just doing something that is done in the 6.x update anyway so it should not be applied to HEAD...
Comment #14
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #15
stormsweeper commentedI'm a little busy right now, but I will provide a patch for pathauto 5.x-2.x tomorrow. Besides the queries listed above, a new constraint needs to be created to make the new name column the primary key once again, since the original constraint is lost upon dropping the old one.
Comment #16
greggles@stormsweeper - please mark as "code needs review" when you have attached the patch.
Otherwise, this is closed. Thanks.