Skip to content

Merge in v1.2 changes - #747

Merged
waldoj merged 49 commits into
masterfrom
v1.2
Aug 5, 2026
Merged

waldoj merged 49 commits into
masterfrom
v1.2

Conversation

@waldoj

@waldoj waldoj commented Aug 5, 2026

Copy link
Copy Markdown
Member
  • Accelerate exporting static files—it's now much faster
  • Move to MySQL's fulltext search, delivering much better results
  • Replace Typekit with Google Fonts
  • Add timestamps to log messages
  • Display a public "last updated" link on every page
  • Add a tally badge to the Pinned Laws menu item
  • Add a generator meta tag

waldoj added 30 commits July 14, 2026 22:15
list_laws() is slow because of running structure_contents() for every law within it, so we memoize per structure, setting up a tiny, one-slot cache. This collapses N calls into just 1. We also simplify the per-sibling $law->get_metadata() loop by using a query that obviates the loop. Note that caching is within the PHP process, not within Memcached or whatever. Toward #622.
Dictionary::term_list() fetches the whole global dictionary for every law, and then Law::render() fetches additional terms that are in scope. So we replace term_list()'s big OR query into two queries, meaning that we can use a one-slot memo cache for the non-structure-scoped bit. Also, we skip the section-scoped part for a global-scope query. Then we unique the two to avoid any duplicates. Toward #622.
Instead of running a single query for each word, combine all of them into a series of smaller ones, capped at 500 per PCRE. We also move this into a function, allowing us to add a one-slot cache, for when this is run repeatedly on laws in the same chapter. Toward #622.
Adds:

<meta name="generator" content="State Decoded v1.1">

(or whatever the version number is) to each page's output. Closes #729.
Without this index, this part of the import is really slow.
Validate that an edition was imported properly.
We were catching it and discarding it, which makes failures a mystery. This fixes that.
Annoyingly, is_writable() returns false for a file that doesn't yet exist, so we're getting inaccurate results around confirming that sitemap.xml can be written to, whether or not it yet exists. So instead we use this new wrapper.
Just rip it out. It's not worth the trouble. #606
I could have sworn that we added this custom function in ~2014, but apparently not, somehow?
Only the web interfaces was running migrations! This led to badness. Here, that badness is eliminated.
We've got some inefficient queries that make it way too slow (and memory-intensive) to record cross-references for an entire code. Here, we optimize these queries.
We had no test coverage for this. Now we do.
This wasn't catching a PHP error, a result of an undefined constant.
glob() wasn't doing it, so now we have a method that will recurse.
EDITION_ID is only defined when importing into the current edition, but not for new editions, resulting in an import failure. This addresses that bug.
Both with and without =, because that's what it's supposed to do.
Skip when laws_references.edition_id is absent.
These give PDO the sadness.
The order of operations before didn't work for a new install, only for upgrades.
After a couple of problems, it seems that a test is needed.
"Done" displayed no matter what, so it wasn't an indicator of success. Now we track how long it takes, and how many laws are imported, reporting that. Also, if the import fails, that's reported, too.
This is slow, and it's difficult to measure progress. This fixes that.
waldoj added 19 commits July 31, 2026 22:12
This was only being handled at the time of export, which meant that simply updating which edition is current wouldn't update the symlink. So we now support updating that symlink when updating the edition, too.
Our checkup function complains if any laws don't have text. But the fact is that some laws sometimes don't have any text! We set a real low threshold here.
Otherwise there's a stale sitemap.
We were blindly assuming that everything exported fine, even as the log racked up tens of thousands of errors. So now we check.
Instead of letting them stream past, let's actually catch them and deal with them.
It was nested within two if statements, which meant that we didn't have an edition name until the database was set up. In this way we ensure that it's always present.
They were all pretty out of date.
This both adds a tally as a badge to the menu item and changes the JavaScript variable that we use to identify a given law. (That was using the Disqus identifier, which was fine as long as Disqus was a thing anybody used.)
It was only 150 pixels wide, far too small. But, also, the size was specified inline, so now it's specified in CSS.
We were using jquery.min.js as a proxy for "have we downloaded front-end assets," which isn't enough anymore. Iterate through a longer list, to ensure we have what we need.
These tests only work for full-text MySQL search, not for our old search setup.
This wasn't possible when we first wrote The State Decoded, but it's possible now! #606
@waldoj
waldoj merged commit a5948d6 into master Aug 5, 2026
1 check passed
@waldoj
waldoj deleted the v1.2 branch August 5, 2026 01:13
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.

1 participant