Review main Merged

43613[TASK] Only use one select to calculate page cache timeout

Alexander Opitz CR +2 V +2 Hard +297 −9 updated 10/11/15, 16:01

Commit message

To get the first time value we do 2 SQL select statements at the
moment but this can be combined in one SQL select statement. This
will save as time and reduces bandwidth to/from the SQL server.

The one SQL select statement from 4.6 had a bug and was changed
to use 2 SQL select statements instead of fixing the statement itself.
So this is a revert to the old source with the fixed statement.

Review

  • Code review CR +2
    • Christian Kuhn +2
    • Morton Jonuschat +1
  • Verified V +2
    • Christian Kuhn +2
    • Morton Jonuschat +1

Issues 1

Files 4

Review log 21

  1. Alexander Opitz uploaded patch set 1 09/28/15, 14:46

  2. Alexander Opitz uploaded patch set 2 09/28/15, 14:46

  3. Benni Mack updated the commit message in patch set 3 10/01/15, 12:05

  4. Wouter Wolters commented on patch set 3 10/01/15, 12:11

    TypoScriptFrontendController.php:4614

    indentation is not correct here

    TypoScriptFrontendController.php:4628

    !empty here

    TypoScriptFrontendController.php:4644

    is_null is slower than !== NULL no space between the cast
  5. Wouter Wolters uploaded patch set 4 10/01/15, 19:58

  6. Wouter Wolters voted on patch set 4 V +1 CR +1 10/01/15, 19:58

  7. Alexander Opitz commented on patch set 4 10/02/15, 06:57

    Thanks Wouter
  8. Daniel Goerz voted on patch set 4 CR +1 V +1 10/02/15, 13:23

  9. Morton Jonuschat commented on patch set 4 CR -1 10/08/15, 16:01

    Looking into it in regard to DBAL compatibility
  10. Oliver Hader uploaded patch set 5 10/08/15, 23:59

  11. Morton Jonuschat commented on patch set 5 CR -1 10/09/15, 06:08

    TypoScriptFrontendController.php:4748

    Isn't MIN() sufficient as there's another check for > $now in line 4770 done in PHP. Only using MIN() would eliminate all DBAL concerns.

    TypoScriptFrontendControllerTest.php:55

    Probably a better wording would be „Expected ... to be X“. Same for the other cases.

    TypoScriptFrontendControllerTest.php:75

    Expected result to be PHP_INT_MAX without matching records.
  12. Alexander Opitz commented on patch set 5 10/09/15, 10:18

    TypoScriptFrontendController.php:4748 Reply

    This hasn't to do with the PHP down below. The command tries to filter out dates before $now, so that they aren't respected in the min calculation. Else our Min select may be in the past (and not the one which is in the future, but we want to know the future). But while reading ... that should be handled in the where condition. *hmmm* Will check.
  13. Morton Jonuschat commented on patch set 5 10/09/15, 11:42

    You're right, just using MIN changes the result of the statement as the condition is starttime OR endtime > now. I'd change the statement to use CASE instead of the MySQL specific IF(), then it should be good on PostgreSQL, Oracle and MySQL afaik.
  14. Morton Jonuschat commented on patch set 5 10/09/15, 11:42

    SELECT MIN(CASE WHEN starttime < 100 THEN NULL ELSE starttime END) AS starttime, MIN(CASE WHEN endtime < 100 THEN NULL ELSE endtime END) AS endtime FROM ....
  15. Alexander Opitz commented on patch set 5 10/09/15, 12:09

    Yes, case is useable. As I started with this patch I only got the hint that there is a DBAL console ... and this console didn't reported me an issue with the statement.
  16. Morton Jonuschat uploaded patch set 6 10/09/15, 20:17

  17. Morton Jonuschat commented on patch set 6 CR +1 V +1 10/09/15, 20:19

    The SQL Parser from DBAL rewrites it to a case statement so it wouldn't fail, but writing standards compliant SQL to begin with makes it easier to work with multiple DBMS. Verified the statement works on MySQL 5.5, MariaDB 10 and PostgreSQL 9.4
  18. Christian Kuhn commented on patch set 6 10/09/15, 20:29

    testing.
  19. Christian Kuhn commented on patch set 6 CR +2 V +2 10/09/15, 20:35

    ok, lets bring this in a second time. this looks solid and the coverage is great. nifty ... thanks guys for the hard work!
  20. Christian Kuhn merged patch set 6 10/09/15, 20:35

  21. Alexander Opitz commented on patch set 7 10/11/15, 16:01

    @morton Ok, good to know, maybe a tool which shows the DBAL transformations would be cool for such statements.