-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add initial functionality and tests #1
Conversation
dlh01
commented
Dec 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work. Left some comments, suggestions, and questions, but nothing blocking. 🍣
.github/workflows/code-quality.yml
Outdated
if: github.event.pull_request.draft == false | ||
uses: alleyinteractive/.github/.github/workflows/php-code-quality.yml@main | ||
with: | ||
php: 8.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend we use 8.2 here
if: github.event.pull_request.draft == false | ||
uses: alleyinteractive/.github/.github/workflows/php-coding-standards.yml@main | ||
with: | ||
php: 8.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also
- main | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
|
||
jobs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good candidate to test out the strategy defined here: alleyinteractive/create-wordpress-project#63
Otherwise, we would have to mark as required each of the matrix jobs with their versions (4 total combinations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read that issue and am not sure I understand it. I'll respond over there.
Scratch that, I read it again and now understand it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried giving each workflow a generic name in 5c46788, but it just made a mess. GitHub ran all the tests under the specific name defined in the upstream workflow anyway. I'm going to leave the next experiment to someone who knows how GHA works better than I do.
README.md
Outdated
@@ -0,0 +1,55 @@ | |||
# PSR16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to make this "WP PSR-16" or something to indicate it's for WordPress specifically in the title.
"extra": { | ||
"wordpress-autoloader": { | ||
"autoload": { | ||
"Alley\\": "src/alley/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specific enough to this library? What about other libraries we maintain that have a namespace of Alley?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, this doesn't prevent other libraries from autoloading files with the Alley
namespace out of their respective src
directories.
phpcs.xml
Outdated
@@ -0,0 +1,49 @@ | |||
<?xml version="1.0"?> | |||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="alleyinteractive/wp-psr16" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XSD reference should be updated to the new repo home:
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="alleyinteractive/wp-psr16" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> | |
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="alleyinteractive/wp-psr16" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd"> |
ref: https://github.com/Automattic/VIP-Coding-Standards/pull/805/files
$out = $default; | ||
|
||
foreach ( $get as $value ) { | ||
$out = $value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that getMultiple would ever return more than one value for this key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible, I guess, but only in the case of an implementation error against the spec. I'll update it just in case.
* @return bool True on success and false on failure. | ||
*/ | ||
public function clear(): bool { | ||
return false; // Not supported by default in WordPress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't supported by default in memcached but there is a way to do this in Redis. Fine to keep as-is for now but we may want to consider a future enhancement where we could keep an inventory of cache keys that could be deleted on a clear operation (maybe in a separate database table even). That's a common enough problem that we run into where a generic solution would be excellent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in Slack, this is "not supported" in the sense that there is no built-in way to delete only the meta keys that have been saved by this library. The library could add support for clear()
by adding its own manifest of cache keys that would then be deleted.
* @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. | ||
*/ | ||
public function getMultiple( iterable $keys, mixed $default = null ): iterable { | ||
$metadata = get_metadata( $this->type, $this->id ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be misunderstanding, but does this library provide functionality for using an object cache implementation for metadata, or does it rely on the underlying WP implementation (e.g., get_metadata
here would attempt to pull from WP's cache, which could be a memcached-backed object cache, but this library doesn't care)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in Slack, it's more the latter: The takeaway for this adapter is that object metadata itself is used as the cache data store. The fact that core also caches object metadata in the persistent object cache is an implementation detail on the part of core.