Previous Thread
Next Thread
Print Thread
Hop To
Joined: Dec 2008
Posts: 26
P
Newbie
Newbie
P Offline
Joined: Dec 2008
Posts: 26
Hi,

I've had SQL errors appearing when I'm managing forums on a board (enabling and disabling forums), and each time I get SQL errors of the form:
Code
[b]Script:[/b] .\forums\admin\doforummanage.php
[b]Line#:[/b] 94
[b]SQL Error:[/b] Incorrect integer value: '' for column 'FORUM_SORT_ORDER' at row 1
[b]SQL Error #:[/b] 1366
[b]Query:[/b] UPDATE ubbt_FORUMS SET FORUM_TITLE = '',FORUM_SORT_ORDER='' WHERE FORUM_ID='360'

Now, this has been benign in the past (i.e. didn't affect functionality), but has now started to prevent us from disabling forums.

I'm running on 7.5.6p2, and I can't imagine that I'm the first person that came across this issue, but I can't find anything on the board about it.

Looking at the source code, I've seen that the "admin/doforummanage.php" file doesn't look particularly efficient (for every forum in the database, it (re-)fetches all of the forum data posted back to the script), nor does it check if the forum found in the database had any data posted back to it by the page.

The code for 7.5.7 hasn't changed in this respect either.

I've modified the code to get the forum data being posted back to the page once only, and to check if the forum found from the SQL query is in the forum data that was posted back, ignoring any forums that are not in the forum data being posted back. This is the context-patch:-
Code
*** ./ubbthreads-7-5-7/admin/doforummanage.php	Tue Jul 02 09:39:07 2013
--- ./forums/admin/doforummanage.php	Tue Jul 02 14:44:03 2013
***************
*** 31,41 ****
  	$forums[$i]['active'] = $active;
  	$i++;
  }
- for ($x=0;$x<$i;$x++) {
- 	$fnum = $forums[$x]['number'];
  	$titles = get_input("forum","post");
  	$orders = get_input("order","post");
  	$active = get_input("active","post");
  	if (!isset($active[$fnum])) {
  		$active[$fnum] = '0';
  	}
--- 57,68 ----
  	$forums[$i]['active'] = $active;
  	$i++;
  }
  $titles = get_input("forum","post");
  $orders = get_input("order","post");
  $active = get_input("active","post");
+ for ($x=0;$x<$i;$x++) {
+ 	$fnum = $forums[$x]['number'];
+ 	if (array_key_exists( $fnum, $titles)) {
  		if (!isset($active[$fnum])) {
  			$active[$fnum] = '0';
  		}
***************
*** 66,71 ****
--- 93,99 ----
  				WHERE FORUM_ID='$fnum'
  			";
  			$dbh->do_query($query,__LINE__,__FILE__);
+ 		}
  	}
  }
  admin_log("FORUM_MANAGE","");

I suspect that the problem is caused by deleting forums, which we do periodically, with the code dealing with the deletions not actually deleting it properly from the database.

I'm still investigating that side of things. In the meantime, any feedback on this issue would be gratefully accepted.

Joined: Dec 2008
Posts: 26
P
Newbie
Newbie
P Offline
Joined: Dec 2008
Posts: 26
I've tracked it down to the forum (FORUM_ID 360) not appearing in any of the categories in the "cache/forum_cache.php" file, which means it doesn't appear in the list of forums that can be managed. (It does, however, appear in the $tree['active'], $tree['kids'] and $tree['tree'] arrays in that cache file.)

Forum 360 was a child forum of forum 359. It seems that forum 359 has been deleted properly, but forum 360 hasn't, and thus still appears in the database, with no way of accessing it.

So...mystery solved. The problem was that the parent forum was deleted first, which meant that the child forum no longer appeared in the list of forums. This meant that the child forum couldn't be deleted, as it wasn't visible any more, but it affected the script.

I can fix the short-term issue, which is to find all orphaned child forums, and delete them manually (by explicitly setting the forumid in the ".../forums/admin/viewboard.php?forum=<forumid>" url path). The long-term automated solution would be either to reparent any child forums that haven't been deleted, or to recursively delete the child forums.


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
spam issues
by ECNet - 03/19/2024 11:45 PM
Looking for a forum
by azr - 03/15/2024 11:26 PM
Editing Links in Post
by Outdoorking - 03/15/2024 9:31 AM
Question on barkrowler and the like
by Mors - 02/29/2024 6:51 PM
Member Permissions Help
by domspeak - 02/27/2024 6:31 PM
Who's Online Now
2 members (Havenofsobriety, rootman), 624 guests, and 106 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)