Error with quick edit: very odd.

Started by Antechinus, July 04, 2009, 10:19:26 PM

Previous topic - Next topic

Antechinus

Running 1.1.9 with several mods, none of which are relevant to this bug AFAIK.

This one is odd because the quick edit works on an admin account but it does not work on a standard member account.
The only conditional statement in Display.template.php is the usual if ($message['can_modify']) and all members have permission to edit their posts.
On this basis I would assume that an admin account would make no difference, but it does.
Attempting to use the quick edit on a standard member account generates this error in the admin log:

http://www.councilofexmuslims.com/index.php?action=quotefast;quote=149136;sesc;modify;xml

Database Error: 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 ')
LIMIT 1' at line 8
File: /home/cofexm/public_html/Sources/Post.php
Line: 2086


Which makes sense as Line 2086 of Post.php is the first one here:

// In case our message has been removed in the meantime.
elseif (isset($_REQUEST['modify']))
{
$context['sub_template'] = 'modifyfast';
$context['message'] = array(
'id' => 0,
'body' => '',
'subject' => '',
);
}


Clicking on the error link in the admin log gives this:

XML Parsing Error: junk after document element
Location: http://www.councilofexmuslims.com/index.php?action=quotefast;quote=149136;sesc;modify;xml
Line Number 14, Column 1:<div align="center" style="margin-top: 2ex;"><a href="javascript:history.go(-1)">Back</a></div>
^


That code is not in Display.template.php, so I'm not sure what to make of it.

Note that the Quick Edit button has been moved from its original location as I'm running a custom template. I've attached it in case it gives people clever ideas about this bug.  ;)

The code for the quick edit starts on Line 376.

Antechinus

Anyone have any thoughts on this? It would be nice to get it fixed.:)

[SiNaN]

It is probably the query that fetches the message information in that function. It shouldn't fail actually. Add this to your Settings.php file:

$db_show_debug = true;

Then reproduce the error. You should be then able to see the complete query causing the error in the Forum Error Log. If you can copy it here, we may have some idea on the issue.
Former SMF Core Developer | My Mods | SimplePortal

Antechinus

Ok, done that. I still get exactly the same error messages as shown in the OP.

[SiNaN]

Okay, you're right. It was for 2.0 probably. Anyway, with that setting applied, and as the user you can reproduce the error, follow the URL given for the error in Forum Error Log. Just change

sesc

to

sesc={your_session_id}

and remove this part of the the URL

;xml

It should then show the full query causing the error.
Former SMF Core Developer | My Mods | SimplePortal

Antechinus

Ok. I'll set it up again tomorrow. I removed the setting again because people were grumbling that there was all this stuff in the footer. :D

Did notice though that if I move the button the errors go away. Seems that it has to be just outside the post div without any other elements in the way. Would that be right, or should it work in pretty much any location as long as the code is right?

[SiNaN]

Moving or putting inside other elements should be fine I guess. Error is odd really, hard to make a guess without seeing the query.
Former SMF Core Developer | My Mods | SimplePortal

Antechinus

Quote from: [SiNaN] on July 23, 2009, 12:00:11 PM
Okay, you're right. It was for 2.0 probably. Anyway, with that setting applied, and as the user you can reproduce the error, follow the URL given for the error in Forum Error Log.
No can do. The thing is that I can only access the error log on an admin account, but when I use an admin account there is no error. To generate the error I need to use a standard member account, and of course I cannot access admin then.


Derine

I had exactly this error, showing up only for non-moderators using the quick-edit button, and I think I solved it.  It was just a syntax error with some parentheses swapped.

The previous code read as:

        $request = db_query("
                SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject, t.locked
                FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
                        LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
                WHERE m.ID_MSG = " . (int) $_REQUEST['quote'] . "
                        AND b.ID_BOARD = m.ID_BOARD
                        AND t.ID_TOPIC = m.ID_TOPIC
                        AND $user_info[query_see_board]" . (!isset($_REQUEST['modify']) || (!empty($moderate_boards) && $moderate_boards[0] == 0) ? '' : '
                        AND (t.locked = 0' . (empty($moderate_boards) ? '' : ' OR b.ID_BOARD IN (' . implode(', ', $moderate_boards)) . ')' . ')') . "
                LIMIT 1", __FILE__, __LINE__);


The fixed code is:

        $request = db_query("
                SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject, t.locked
                FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
                        LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
                WHERE m.ID_MSG = " . (int) $_REQUEST['quote'] . "
                        AND b.ID_BOARD = m.ID_BOARD
                        AND t.ID_TOPIC = m.ID_TOPIC
                        AND $user_info[query_see_board]" . (!isset($_REQUEST['modify']) || (!empty($moderate_boards) && $moderate_boards[0] == 0) ? '' : '
                        AND (t.locked = 0' . (empty($moderate_boards) ? '' : ' OR b.ID_BOARD IN (' . implode(', ', $moderate_boards) . ')') . ')') . "
                LIMIT 1", __FILE__, __LINE__);


The only portion changed was rearranging the  mess of closing parentheses, quote marks, and periods at the end of the second-last line, and now the error is gone and the feature works for moderators and non-moderators.

Antechinus

I'd forgotten about this. Well spotted. Tried it and it seems to work perfectly for all member groups in all browsers. I'll look at getting this change added into 1.1.x before we end up needing 1.1.14.

Advertisement: