#6508 closed defect (bug) (duplicate)
Gallery does not work on my hosting
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | |
Component: | General | Keywords: | Media gallery has-patch |
Focuses: | Cc: |
Description
I'm not sure of the difference, but on my hosting (and others as well as seen here http://wordpress.org/support/topic/163938?replies=7) the Gallery function does not work.
I get a php error
[31-Mar-2008 07:32:03] WordPress 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 '\"menu_order ASC, ID ASC\" DESC' at line 1 for query SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_type = 'attachment' AND wp_posts.post_parent = 15 AND (post_mime_type LIKE 'image/%') GROUP BY wp_posts.ID ORDER BY \"menu_order ASC, ID ASC\" DESC made by get_posts
In the investigation that I have done, this seems to be related to the call to get children in gallery_shortcode function in wp-includes/media.php
$attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby=\"{$orderby}\"");
As far as I can see the {$orderby} should not be in quotes, and also the order parameter should be overridden as the function get_posts in post.php adds DESC to the end anyway.
All in all we end up with this
ORDER BY \"menu_order ASC, ID ASC\" DESC
being sent to SQL and it has a hissy fit !!
What I am not sure about is why this code seems to work for some people, and also on my WAMP setup on my own PC...?
I will try to come up with a patch, but in the mean time, I thought I ought to inform the world.
Attachments (1)
Change History (11)
#1
@
16 years ago
- Keywords Media gallery added
- Milestone changed from 2.7 to 2.5.1
- Severity changed from normal to major
#2
@
16 years ago
Added a patch... this works for me.. but not sure if it mucks anything else up, also the fact that I have taken the double quotes off it causes any security issue.
I have tried it with single and double quotes around the orderby but both fail.
I also added the order attribute as blank as the actual order is specified in the orderby.
#3
follow-up:
↓ 5
@
16 years ago
Applying the patch causes galleries not to be displayed for me. What versions of PHP and MySQL are you running?
#5
in reply to:
↑ 3
@
16 years ago
Replying to ionfish:
Applying the patch causes galleries not to be displayed for me. What versions of PHP and MySQL are you running?
Oops..
PHP/5.2.0
Apache version 1.3.37 (Unix)
MySQL version 4.1.22-standard-log
How odd
#6
@
16 years ago
See this http://trac.wordpress.org/ticket/6476 also
#8
@
16 years ago
I don't agree that 6476 is a duplicate; that bug deals with a working, albeit wrong, SQL query. In this case, the query results in a syntax error. It should be interesting for future knowledge to understand why this admittedly wrong sql query is generating syntax error only on a very small number of configurations.
Anyway, I have the same problem, using: MySQL 5.0.32, Apache/2.2.3 (Debian) and PHP 5.2.0-8+etch7.
Dickie let me know if you find something. See also here: http://wordpress.org/support/topic/164540?replies=1
#10
@
16 years ago
In this thread, user Velenux found out that the culprit could be the magic quotes setting in php. Disabling it seems to work (confirmed also by other users).
Fix for Gallery problem