Editing A Record Removes Most Subject Associations

1 view
Skip to first unread message

Gavin

unread,
Oct 14, 2009, 12:44:59 PM10/14/09
to SubjectsPlus
Sorry for finding another *potential* bug. I'm not actively trying to
find any... really I'm not! I guess I'm just "lucky". ;)

I found that when I edit a record and click the Save Changes button,
all subjects except one would disappear for that record. I have my
database backed up, can easily restore it and test again. I turned on
the debugging for control/records/record.php and the following SQL
querys were displayed:

update title set title="Oxford Reference Online", description="",
pre="", last_modified_by="spo...@cwu.edu", last_modified="2009-10-14
08:10:13" where title_id = 70;

delete from rank where title_id = 70;

insert into rank(rank, subject_id, title_id, source_id,
description_override) values("100", "1", "70", "8", "");

insert into rank(rank, subject_id, title_id, source_id,
description_override) values("100", "2", "70", "8", "");

update location set format = "1", location="http://
www.oxfordreference.com", access_restrictions="1", limit2="1",
location.fulltextCol="Y", eres_display="", display_note="",
article_linker="", image_files="", video_files="", audio_files=""
where location_id = "70";

Before clicking Save Changes, Oxford Reference Online is associated
with all of our subjects, then after it is only associated with
Accounting. The first insert query above is for Accounting because the
subject_id for that is 1. The second one is for Anthropology and
Museum Studies, but even though the debugging outputs this SQL, it
doesn't get applied. I looked at the rank table for title_id=70 and
there's only one record, the one for Accounting.

I tried this with another record and it did the same thing. I also
added a record and the same applied to that one as well.

Is anyone else experiencing this? I'm working with a test installation
of v0.9 that I imported and upgraded the data from our current 0.8
version, so it may be related to that. I may install a fresh, separate
installation and see if it still does this.

- Gavin

Gavin

unread,
Oct 14, 2009, 2:14:40 PM10/14/09
to SubjectsPlus
I found out a little bit more, thanks in part to Andrew's "debugger
switch" and adding some debugging code of my own, but am still
perplexed.

In control/records/edit_functions.php I added the following after line
55:

print "<p class=\"debugger\">\$rank_count = $rank_count</p>";

That printed out the correct number of subjects (30) that were
associated with the record, so the for-loop should iterate that many
times and insert all those into the rank table. Then I noticed that at
the end of the for-loop there was the condition:

if($rank_result == FALSE) return FALSE;

So I changed it to:

if($rank_result == FALSE)
{
print "<p class=\"debugger\">\$q = $q</p>";
return FALSE;
}

And the output in my browser was:

$q = insert into rank(rank, subject_id, title_id, source_id,
description_override) values("100", "2", "70", "8", "")

Why would running that query return FALSE? Looks okay to me.

- Gavin

On Oct 14, 9:44 am, Gavin <thisguyik...@gmail.com> wrote:
> Sorry for finding another *potential* bug. I'm not actively trying to
> find any... really I'm not! I guess I'm just "lucky". ;)
>
> I found that when I edit a record and click the Save Changes button,
> all subjects except one would disappear for that record. I have my
> database backed up, can easily restore it and test again. I turned on
> the debugging for control/records/record.php and the following SQL
> querys were displayed:
>
>    update title set title="Oxford Reference Online", description="",
> pre="", last_modified_by="spom...@cwu.edu", last_modified="2009-10-14
> 08:10:13" where title_id = 70;
>
>    delete from rank where title_id = 70;
>
>    insert into rank(rank, subject_id, title_id, source_id,
> description_override) values("100", "1", "70", "8", "");
>
>    insert into rank(rank, subject_id, title_id, source_id,
> description_override) values("100", "2", "70", "8", "");
>
>    update location set format = "1", location="http://www.oxfordreference.com", access_restrictions="1", limit2="1",

Gavin

unread,
Oct 14, 2009, 2:31:35 PM10/14/09
to SubjectsPlus
Found the problem... finally. And it was my own damned fault! :)

Andrew, in the SQL modifications I sent you for upgrading to v0.9,
there was a line that was:

ALTER TABLE `rank` MODIFY `rank_id` bigint(20);

It should be:

ALTER TABLE `rank` MODIFY `rank_id` bigint(20) NOT NULL
auto_increment;

My bad. Sorry if I screwed anyone up with that. I'll try to be more
thorough next time.

- Gavin
Reply all
Reply to author
Forward
0 new messages