Commit Graph

380 Commits

Author SHA1 Message Date
Naz
7c18263227 Extracted adapter-cache-redis from core codebase
refs https://github.com/TryGhost/Toolbox/issues/515

- This implementation allows to use Redis cluster as a caching adapter. The cache adapter can be configured through same adapter configuration interface as others. It accepts following config values:
  - "ttl" - time in SECONDS for stored entity to live in Redis cache
  - "keyPrefix" - special cache key prefix to use with stored entities
  - "host" / "port" / "password" / "clusterConfig" - Redis instance specific configs
- Set test coverage to non-standard 75% because the code mostly consists of the glue code that would require unnecessary Redis server mocking and would be a bad ROI. This module has been used in production for a long time already, so can be considered pretty stable.
2023-02-13 19:01:43 +08:00
Naz
5216220541 Public tags repository caching
refs https://github.com/TryGhost/Toolbox/issues/515

- There are a lot of repeated cacheable tag-related queries coming from
{{get}} helpers in themes that can be cached.
- Having a repository layer deal with very specific type of query allows
to add extra functionality, like caching, on top of the database query
- This commit is wiring code that addds a default in-memory cache to
all db queries. Note, it lasts forever and has no "reset" listeners. The
production cache is mean to have a short time-to-live (TTL) - removes a need
to keep the cache always fresh.
- Kept the cache key shortened. Without a "context" and any other non-model options the cache-key can store more variations of queries. For example, there is no member-specific or integration-specific query results, so having those in the cache key would only partition the cache and use up more memory.
2023-02-13 19:01:43 +08:00
renovate[bot]
3a11525ad7
Update dependency mysql2 to v3.1.2 2023-02-09 20:10:27 +00:00
Daniel Lockyer
d750612508
Merged v5.33.8 into main
v5.33.8
2023-02-09 10:08:43 +01:00
Ghost CI
83bf4ccb53 v5.33.8 2023-02-09 09:06:34 +00:00
renovate[bot]
fd79ca3f5a Update dependency html-validate to v7.13.2 2023-02-09 09:30:14 +01:00
Ghost CI
c518446c17 Merged v5.33.7 into main 2023-02-07 10:32:47 +00:00
Ghost CI
ca568817dd v5.33.7 2023-02-07 10:32:43 +00:00
renovate[bot]
654a991c98 Update dependency mysql2 to v3.1.1 2023-02-07 09:20:11 +01:00
Ghost CI
d37ed200ab Merged v5.33.6 into main 2023-02-03 13:41:48 +00:00
Ghost CI
8e72332c77 v5.33.6 2023-02-03 13:41:45 +00:00
Ghost CI
509affb1f7 Merged v5.33.5 into main 2023-02-02 16:33:50 +00:00
Ghost CI
771a6182c7 v5.33.5 2023-02-02 16:33:46 +00:00
Ghost CI
f90d6ca66b Merged v5.33.4 into main 2023-02-02 13:33:14 +00:00
Ghost CI
3f5e34f840 v5.33.4 2023-02-02 13:33:10 +00:00
renovate[bot]
5367fa94cc
Update dependency sanitize-html to v2.9.0 2023-02-01 15:39:45 +00:00
Ghost CI
a444d2e703 Merged v5.33.3 into main 2023-02-01 11:07:22 +00:00
Ghost CI
e82ed951f4 v5.33.3 2023-02-01 11:07:19 +00:00
Ghost CI
356c370905 Merged v5.33.2 into main 2023-01-31 14:37:47 +00:00
Ghost CI
444ca6f5e5 v5.33.2 2023-01-31 14:37:44 +00:00
renovate[bot]
02ca1940f8 Update dependency mysql2 to v3.1.0 2023-01-31 10:16:05 +01:00
renovate[bot]
5ab7654695 Update Test & linting packages 2023-01-31 05:44:54 +00:00
Ghost CI
b9b51ee309 Merged v5.33.1 into main 2023-01-30 16:18:18 +00:00
Ghost CI
249942892a v5.33.1 2023-01-30 16:18:14 +00:00
Simon Backx
8e66edee2b
🐛 Fixed storing original files for images (#16117)
fixes https://github.com/TryGhost/Team/issues/481

This change fixes an issue when multiple images with the same name are
uploaded in parallel. The current system does not guarantee that the
original filename is stored under NAME+`_o`, because the upload for the
original file and the resized file are happening in parallel.

Solution:
- Wait for the storage of the resized image (= the image without the _o
suffix) before storing the original file.
- When that is stored, use the generated file name of the stored image
to generate the filename with the _o suffix. This way, it will always
match and we don't risk both files to have a different number suffix.
We'll also set the `targetDir` argument when saving the file, to avoid
storing the original file in a different directory (when uploading a
file around midnight both files could be stored in 2023/01 and 2023/02).

Some extra optimisations needed with this fix:
- Previously when uploading image.jpg, while it already exists, it would
store two filenames on e.g., `image-3.jpg` and `image_o-3.jpg`. Note the
weird positioning of `_o`. This probably caused bugs when uploading
files named `image-3.jpg`, which would store the original in
`image-3_o.jpg`, but this original would never be used by the
handle-image-sizes middleware (it would look for `image_o-3.jpg`). This
fix would solve this weird naming issue, and make it more consistent.
But we need to make sure our middlewares (including handle-image-sizes)
will be able to handle both file locations to remain compatible with the
old format. This isn't additional work, because it would fix the old bug
too.
- Prevent uploading files that end with `_o`, e.g. by automatically
stripping that suffix from uploaded files. To prevent collisions.

Advantage(s):
- We keep the original file name, which is better for SEO.
- No changes required to the storage adapters.

Downside(s):
- The storage of both files will nog happen parallel any longer. But I
expect the performance implications to be minimal.
- Changes to the routing: normalize middleware is removed
2023-01-30 16:40:50 +01:00
Ghost CI
829c325e51 v5.33.0 2023-01-27 16:00:43 +00:00
Daniel Lockyer
693db59f73
Merged v5.32.0 into main
v5.32.0
2023-01-25 15:34:26 +01:00
Ghost CI
b1b24a6884 v5.32.0 2023-01-25 14:32:26 +00:00
renovate[bot]
cbdd866dc7 Update dependency @playwright/test to v1.30.0 2023-01-25 08:40:36 +01:00
renovate[bot]
929d32dddf Update dependency knex to v2.4.2 2023-01-23 13:00:53 +01:00
Naz
714a6f6900
Updated sitemaps to react to a partial resource update
refs https://github.com/TryGhost/Toolbox/issues/503

- The Dynamic URL service no longer generates "url.added" event when only a partial resource update happened - only non-url forming properties were modified. The sitemaps service still needs to know when to update the lastmod ("Last Modified") field associated with specific URL.
2023-01-23 16:33:41 +08:00
Ghost CI
ff1039bcbe v5.31.0 2023-01-20 16:01:01 +00:00
Daniel Lockyer
34fe49b110
Added version information to log lines
refs https://github.com/TryGhost/Toolbox/issues/501

- this reverts commit 48dda23554
- also includes a resolution for `@elastic/elasticsearch` so we don't
  run a version that is potentially problematic - see referenced issue
  for context
2023-01-20 13:18:44 +01:00
renovate[bot]
81fe4840dd Update dependency postcss to v8.4.21 2023-01-20 09:07:51 +01:00
Simon Backx
acf0baa8c7 Updated express-test to 0.13.0
no issue

This includes support for uploading files in tests.
2023-01-18 11:42:42 +01:00
renovate[bot]
28ed23c13e Update dependency knex to v2.4.1 2023-01-18 07:43:07 +01:00
Daniel Lockyer
48dda23554
Reverted "Added version information to log lines"
refs https://github.com/TryGhost/Toolbox/issues/501

- this reverts commit f2116357b7
- something with Elasticsearch is causing high CPU usage, so this commit
  reverts that for now
2023-01-17 13:20:47 +01:00
Fabien "egg" O'Carroll
1babf6126a Added initial basic Mentions implementation
refs https://github.com/TryGhost/Team/issues/2416

This extends the mock API to use a more formal pattern of moving our
entity code into a separate package, and use the service/repository
patterns we've been work toward.

The repository is currently in memory, this allows us to start using
the API without having to make commitments to the database structure.

We've also injected a single fake webmention for testing. I'd expect
the Mention object to change a lot from this initial definition as we
gain more information about the type of data we expect to see.
2023-01-17 17:01:20 +07:00
renovate[bot]
3d79d10ddf Update dependency mysql2 to v3.0.1 2023-01-17 08:22:53 +01:00
Naz
112ab23968
Removed direct use of @tryghost/jest-snapshot
refs https://github.com/TryGhost/Toolbox/issues/499
refs 6bcc47a0ad

- Using module directly caused issues with snapshots manager instance initialization (mocha hooks did not apply to a correct instance)
- See refed commit for more
2023-01-17 12:50:49 +08:00
Naz
1f6b2b4d5e
Added email content testing capabilities
refs https://github.com/TryGhost/Toolbox/issues/499

- Outgoing emails have been a weak point of Ghost's stability recently. The concept of "emailMockReceiver" similarly to "webhookMockReceiver", allows to test side-effects like outgoing emails.
- This is a first iteration which should lay groundwork for testing all outgoing emails in the future
- The change adds a new concept of "email mock receiver" which is very similar to how the "webhook mock receiver" works. The email mock receiver exposes two methods to record and verify snapshots:
- matchHTMLSnapshot - records and verifies only the HTML content of the outgoint email
- matchMetadataSnapshot - records and verifies all the non-HTML properties sent along an email content, e.g.: to address, plaintext, subject, etc.
- What's missing is matching content based on dynamic content like dates, links with JWT tokens, etc.
2023-01-17 12:50:49 +08:00
renovate[bot]
e95cff2ef4 Update dependency glob to v8.1.0 2023-01-16 09:59:45 +01:00
renovate[bot]
15c6fbb12a Update dependency html-validate to v7.13.1 2023-01-16 09:57:58 +01:00
Ghost CI
460d2dc339 v5.30.1 2023-01-16 05:35:14 +00:00
renovate[bot]
9dda708305
Update dependency eslint to v8.32.0 2023-01-16 00:19:30 +00:00
Ghost CI
2884521195 v5.30.0 2023-01-13 16:00:44 +00:00
renovate[bot]
a990769e31 Update dependency jwks-rsa to v3.0.1 2023-01-13 14:07:10 +01:00
renovate[bot]
bb2ffee69d Update dependency @playwright/test to v1.29.2 2023-01-12 11:35:22 +01:00
Sam Lord
f2116357b7 Added version information to log lines
refs: https://github.com/TryGhost/Toolbox/issues/502

Updated to @tryghost/logging@2.4.0 to allow metadata to be logged
2023-01-12 10:34:23 +00:00
Daniel Lockyer
9b38bd9509
🐛 Fixed ECONNRESET error when connecting to Azure MySQL DB
fixes https://github.com/TryGhost/Ghost/issues/14990

- there was a bug in `mysql2` [1] when connecting to Azure DBs, but this was
  subsequently fixed, so this commit bumps the package in Ghost and
  `knex-migrator`, where this was also bumped
- of note, this release includes https://github.com/sidorares/node-mysql2/pull/1666 and
  https://github.com/sidorares/node-mysql2/pull/1751, which are very interesting

[1]: https://github.com/sidorares/node-mysql2/pull/1438
2023-01-12 10:46:09 +01:00