Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update legacy.php for postgresql Pagination error #5009

Closed
wants to merge 1 commit into from
Closed

Update legacy.php for postgresql Pagination error #5009

wants to merge 1 commit into from

Conversation

Humorlos
Copy link
Contributor

@Humorlos Humorlos commented Nov 7, 2014

See #5008

@Humorlos Humorlos changed the title Update legacy.php Update legacy.php for postgresql Pagination error Nov 7, 2014
@Bakual
Copy link
Contributor

Bakual commented Nov 7, 2014

See comment on #5010

@Bakual
Copy link
Contributor

Bakual commented Nov 7, 2014

The part with $query2 doesn't make any sense to me. Leftover from testing?

@Humorlos
Copy link
Contributor Author

Humorlos commented Nov 7, 2014

Hello, I rechecked it, and with the solution from #5010 it is obsolete, you are right.

Before it made sense, because in postgres to original database query looked like that:

For the starting page with Offset 0:

SELECT COUNT(*) FROM #__content AS a LEFT JOIN #__content_frontpage AS fp ON fp.content_id = a.id LEFT JOIN #__categories AS c ON c.id = a.catid LEFT JOIN #__users AS ua ON ua.id = a.created_by LEFT JOIN #__users AS uam ON uam.id = a.modified_by LEFT JOIN #__categories as parent ON parent.id = c.parent_id LEFT JOIN #__content_rating AS v ON a.id = v.content_id LEFT OUTER JOIN (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = 'com_content' AND parent.published != 1 GROUP BY cat.id ) AS badcats ON badcats.id = c.id WHERE a.access IN (1,1,5) AND c.access IN (1,1,5) AND CASE WHEN badcats.id is null THEN a.state ELSE 0 END = 1 AND (a.catid = 13 OR a.catid IN ( SELECT sub.id FROM #__categories as sub INNER JOIN #__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt WHERE this.id = 13)) AND (a.publish_up = '1970-01-01 00:00:00' OR a.publish_up <= '2014-11-07 14:49:04') AND (a.publish_down = '1970-01-01 00:00:00' OR a.publish_down >= '2014-11-07 14:49:04')

For example with offset 4:

SELECT COUNT(*) FROM #__content AS a LEFT JOIN #__content_frontpage AS fp ON fp.content_id = a.id LEFT JOIN #__categories AS c ON c.id = a.catid LEFT JOIN #__users AS ua ON ua.id = a.created_by LEFT JOIN #__users AS uam ON uam.id = a.modified_by LEFT JOIN #__categories as parent ON parent.id = c.parent_id LEFT JOIN #__content_rating AS v ON a.id = v.content_id LEFT OUTER JOIN (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = 'com_content' AND parent.published != 1 GROUP BY cat.id ) AS badcats ON badcats.id = c.id WHERE a.access IN (1,1,5) AND c.access IN (1,1,5) AND CASE WHEN badcats.id is null THEN a.state ELSE 0 END = 1 AND (a.catid = 13 OR a.catid IN ( SELECT sub.id FROM #__categories as sub INNER JOIN #__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt WHERE this.id = 13)) AND (a.publish_up = '1970-01-01 00:00:00' OR a.publish_up <= '2014-11-07 14:49:17') AND (a.publish_down = '1970-01-01 00:00:00' OR a.publish_down >= '2014-11-07 14:49:17') OFFSET 4

the first statement returns a value for Count(), the second on returns nothing. Therefore there was my workaround with the encapsuled query so that the count() is working proberly again in postgres.

But as stated above, with the change in #5010 and eliminating the offset you don't need it any more.

@Bakual
Copy link
Contributor

Bakual commented Nov 7, 2014

So I'm closing this based on your comment

@Bakual Bakual closed this Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants