| @@ -21,9 +21,11 @@ | ||
| 21 | 21 | * module is enabled AND someone presses Test / runs the command. There is |
| 22 | 22 | * no schedule, no background call, no telemetry — see readme.txt "External |
| 23 | 23 | * services". |
| 24 | 24 | * |
| 25 | - * Storage: `xspeed_score_history`, capped, autoload off. The row shape | |
| 25 | + * Storage: the `xspeed_scores` table (Score_Store). The legacy | |
| 26 | + * `xspeed_score_history` option, capped and autoload off, is written only | |
| 27 | + * when the table refuses a row. The row shape | |
| 26 | 28 | * matches what Pro's Pagespeed engine already returns (ok/status/url/ |
| 27 | 29 | * strategy/score/metrics/issues) so a Pro run and a Free run are the same |
| 28 | 30 | * kind of row and the history stays one series. |
| 29 | 31 | * |
| @@ -441,9 +443,17 @@ | ||
| 441 | 443 | // The table is the store. It is created on activation and on |
| 442 | 444 | // admin_init, but record() can run from CLI on a site that has done |
| 443 | 445 | // neither yet, so make sure it exists before writing. |
| 444 | 446 | Score_Store::maybe_install(); |
| 445 | - Score_Store::insert( $row, isset( $row['source'] ) ? (string) $row['source'] : 'local' ); | |
| 447 | + $id = Score_Store::insert( $row, isset( $row['source'] ) ? (string) $row['source'] : 'local' ); | |
| 448 | + | |
| 449 | + // The option is only the fallback for a site where the table could | |
| 450 | + // not take the row. Writing it on every run as well kept a second, | |
| 451 | + // PHP-serialized copy that a latin1 options table can corrupt the | |
| 452 | + // same way it corrupted the scan result (#468). | |
| 453 | + if ( $id > 0 ) { | |
| 454 | + return; | |
| 455 | + } | |
| 446 | 456 | |
| 447 | 457 | $history = self::history_option(); |
| 448 | 458 | array_unshift( $history, $row ); |
| 449 | 459 | if ( count( $history ) > self::MAX_HISTORY ) { |