Gossamer Forum
Quote Reply
Modifying...
I've just stumbled across a problem when writing a plugin. Basically, it seems that the Modify function does not work correctly. I am defining LinkID in the query string, so the old URL does not need to be entered.

It is holding the LinkID value correctly;

<input type="hidden" name="LinkID" value="27">

...but after submitting when the modification was made, I get;


------------------------------------------------------------
A fatal error has occured:
Can't call method "rows" on an undefined value at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links/User/Modify.pm line 166.

Please enable debugging in setup for more details.
Stack Trace
======================================
Links (67043): Links::environment called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links.pm line 431 with no arguments.
Links (67043): Links::fatal called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links/User/Modify.pm line 166 with arguments
    (Can't call method "rows" on an undefined value at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links/User/Modify.pm line 166.
        ).
Links (67043): Links::User::Modify::modify_link called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/GT/Plugins.pm line 91 with arguments
    (HASH(0x824340c)).
Links (67043): GT::Plugins::dispatch called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links/User/Modify.pm line 47 with arguments
    (GT::Plugins, /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Plugins, user_modify_link, CODE(0x81c9228), HASH(0x824340c)).
Links (67043): Links::User::Modify::_modify called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Links/User/Modify.pm line 32 with no arguments.
Links (67043): Links::User::Modify::handle called at /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/GT/Plugins.pm line 91 with no arguments.
Links (67043): GT::Plugins::dispatch called at modify.cgi line 25 with arguments
    (GT::Plugins, /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/Plugins, handle_modify, CODE(0x81aaae8)).


System Information
======================================
Perl Version: 5.00503
Links SQL Version: 2.1.2
DBI.pm Version: 1.21
Persistant Env: mod_perl (0) SpeedyCGI (0)
GT::SQL::error = Failed to execute query: 'SELECT * FROM Links WHERE IS NULL ' Reason: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NULL' at line 1
@INC =
/home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin
/usr/libdata/perl/5.00503/mach
/usr/libdata/perl/5.00503
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005
.

CGI INPUT
======================================
CatLinks.CategoryID => 1
Contact_Email => ererer
Contact_Name => andy
Description => just a test dewdc
LinkID => 27
Title => new tsting title
URL => http://www.crap.com
d => 1
modify => 1
sample1 => C:\WINDOWS\Desktop\backups\linkssql.net\images\bg_content.jpg
sample2 => C:\WINDOWS\Desktop\backups\linkssql.net\images\fl3_07-link1_over.jpg
sample3 =>
sample4 =>
sample5 =>
sample6 =>
upload1 =>


CGI Cookies
======================================
MySQLMan_host => localhost
MySQLMan_password => ******
MySQLMan_url => mysql.cgi?table=Links;data_source=DBI%3Amysql%3Alsql2;do=browse;page=1;action=browse
MySQLMan_username => ******


ENVIRONMENT
======================================
CONTENT_LENGTH => 14966
CONTENT_TYPE => multipart/form-data; boundary=---------------------------7d31ea2f430
DOCUMENT_ROOT => /htdocs/rjones/linkssql.net
GATEWAY_INTERFACE => CGI/1.1
GT_TMPDIR => /home/htdocs/users/rjones/rjones/linkssql.net/cgi-bin/search/admin/tmp
HTTP_ACCEPT => */*
HTTP_ACCEPT_ENCODING => gzip, deflate
HTTP_ACCEPT_LANGUAGE => en-gb
HTTP_CACHE_CONTROL => no-cache
HTTP_CONNECTION => Keep-Alive
HTTP_HOST => www.linkssql.net
HTTP_REFERER => http://www.linkssql.net/cgi-bin/search/modify.cgi?d=1&LinkID=27
HTTP_USER_AGENT => Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
PATH => /usr/local/bin:/usr/bin:/bin
QUERY_STRING =>
REMOTE_ADDR => 172.187.108.111
REMOTE_PORT => 1476
REQUEST_METHOD => POST
REQUEST_URI => /cgi-bin/search/modify.cgi
SCRIPT_FILENAME => /htdocs/rjones/linkssql.net/cgi-bin//search/modify.cgi
SCRIPT_NAME => /cgi-bin/search/modify.cgi
SERVER_ADDR => 64.255.42.69
SERVER_ADMIN => webmaster@linkssql.net
SERVER_NAME => www.linkssql.net
SERVER_PORT => 80
SERVER_PROTOCOL => HTTP/1.1
SERVER_SOFTWARE => Apache/1.3.27 (Unix) PHP/4.3.0 mod_ssl/2.8.10 OpenSSL/0.9.6e

------------------------------------------------------------

The bit in red is obviously the problematic code, but I can't see any reason in /admin/Links/Users/Modify.pm for it to be brining up these errors. The place think the error is being reported is;

Code:
my ($link, $sth);
if ($USER and $lid) {
$sth = $db->select ( { ID => $lid, LinkOwner => $USER->{Username} });
$sth->rows or return { error => Links::language('MODIFY_BADURL', $lid), Category => $category, LinkID => $lid };
}
else {
$sth = $db->select ( { $column => $value } );
$sth->rows or return { error => Links::language('MODIFY_BADURL', $value), Category => $category, LinkID => $lid };
}
$link = $sth->fetchrow_hashref;

Could it be down to the fact the select does not seem to be setup correctly?

select ( { $column => $value } )

...shouldn't it be;

select ( { URL => $IN->param('URL') } );

I'm totally confused Unimpressed

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Modifying... In reply to
Can anyone confirm this problem?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Modifying... In reply to
Bug reported to GT. I've tested the modify function, with file uploads, on several different installations of 2.1.2, and all of them have the problem Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Modifying... In reply to
Hey Andy,

Thanks for the report. I'm looking at it right now and you're right, it seems to be doing some magic in there. Changing $column to URL will work for that instance but I'm worried that it may break something elsewhere.

It currently seems to assume that you have a Current_URL value among your entries. If it is missing, $column and $value will be missing. Just hard coding some cases in there may be the easiest way to clear up this issue but there may be another reason and let me ask around to make sure that such a change is ok.

Cheers,
Aki
Quote Reply
Re: [Aki] Modifying... In reply to
No problem. I was almost going to start hacking at it today, once I completed another project. My Thumb_Images plugin is coming along nicely, but admin and user side modifications are not working, due to the fact of this part of the script being broken Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Aki] Modifying... In reply to
BTW: Would you be able to post the modifications needed to fix this when you find a fix? Obviously the fix will not be coded in until the next version, and a lot of people will still be using 2.1.2 for a while, so I need to put a note in the installation instructions on what they need to do to make the 'modify' section work Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Modifying... In reply to
Hi Andy,

The fix is simple. Change line 153 from
Code:
if (! ($value or $lid)) {
to
Code:
if (! ($value or ($lid and $USER))) {

Although a bug and the fix has been applied to the CVS copy already, it generally won't be seen unless something strange or a plugin is used that accesses Links SQL specificically with a LinkID and the user is not logged in.

Just to prevent other bad things happening, I wouldn't recommend other people from making this patch to their version unless it really is a problem. The with the current template set, the situation will not occur.
Quote Reply
Re: [Andy] Modifying... In reply to
Andy,

Any chance you can make a plugin that will allow modification entirely based on ID and not URL? For portals that are not based on URLs the modify function is useless.

BTW, I never received a reply to my last email to you (about custom plugins). Did you get it? I know the email has been problematic.

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Modifying... In reply to
Unfortunatly not. I'm pretty booked up at the moment.

>>>BTW, I never received a reply to my last email to you (about custom plugins). Did you get it? I know the email has been problematic. <<<

Can't say I remember getting it. Could you possibly PM me it instead?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!