Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/publishpress-authors/defines.php
+++ b/publishpress-authors/defines.php
@@ -12,7 +12,7 @@
defined('ABSPATH') or die('No direct script access allowed.');
if (!defined('PP_AUTHORS_LOADED')) {
- define('PP_AUTHORS_VERSION', '4.20.0');
+ define('PP_AUTHORS_VERSION', '4.20.1');
define('PP_AUTHORS_FILE', 'publishpress-authors/publishpress-authors.php');
define('PP_AUTHORS_BASE_PATH', plugin_dir_path(__DIR__ . '/publishpress-authors.php'));
define('PP_AUTHORS_MODULES_PATH', PP_AUTHORS_BASE_PATH . 'src/modules/');
--- a/publishpress-authors/lib/vendor/composer/installed.php
+++ b/publishpress-authors/lib/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => '__root__',
- 'pretty_version' => 'v4.20.0',
- 'version' => '4.20.0.0',
- 'reference' => '54d382a22cb305eab9e01ef64ff2bc2e2b84a740',
+ 'pretty_version' => 'v4.20.1',
+ 'version' => '4.20.1.0',
+ 'reference' => 'a8dc5628a75627237c3a852a8f6999b5761bb3b7',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,9 +11,9 @@
),
'versions' => array(
'__root__' => array(
- 'pretty_version' => 'v4.20.0',
- 'version' => '4.20.0.0',
- 'reference' => '54d382a22cb305eab9e01ef64ff2bc2e2b84a740',
+ 'pretty_version' => 'v4.20.1',
+ 'version' => '4.20.1.0',
+ 'reference' => 'a8dc5628a75627237c3a852a8f6999b5761bb3b7',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
--- a/publishpress-authors/publishpress-authors.php
+++ b/publishpress-authors/publishpress-authors.php
@@ -5,7 +5,7 @@
* Description: PublishPress Authors allows you to add multiple authors and guest authors to WordPress posts
* Author: PublishPress
* Author URI: https://publishpress.com
- * Version: 4.20.0
+ * Version: 4.20.1
* Text Domain: publishpress-authors
* Domain Path: /languages
* Requires at least: 5.5
--- a/publishpress-authors/src/core/Classes/Post_Editor.php
+++ b/publishpress-authors/src/core/Classes/Post_Editor.php
@@ -1092,8 +1092,12 @@
/*
* If the user can't edit others posts, we shouldn't set another user as author for the post.
* That could bring back a bug that blocks them to create new posts.
+ * Their own author profile is fine, otherwise their new posts get no author term.
*/
- if (! current_user_can('edit_others_posts') && ! $defaultAuthor->is_guest()) {
+ if (! current_user_can('edit_others_posts')
+ && ! $defaultAuthor->is_guest()
+ && (int) $defaultAuthor->user_id !== get_current_user_id()
+ ) {
return;
}
--- a/publishpress-authors/src/core/Mcp/Settings.php
+++ b/publishpress-authors/src/core/Mcp/Settings.php
@@ -30,7 +30,7 @@
'update-plugin-settings',
__('Update Authors settings', 'publishpress-authors'),
__('Patch only supplied Authors settings; preserves unrelated settings. Use get-plugin-settings for exact fields and native choices. dry_run validates and returns proposed values without saving. Author Pages changes refresh rewrite rules. Pro branding requires Pro.', 'publishpress-authors'),
- Registry::object(['settings' => array_merge(self::schema(), ['minProperties' => 1, 'maxProperties' => 100]), 'dry_run' => Registry::preview()], ['settings']),
+ Registry::object(['settings' => array_merge(self::schema(true), ['minProperties' => 1, 'maxProperties' => 100]), 'dry_run' => Registry::preview()], ['settings']),
$output,
[__CLASS__, 'update'],
[Capability::class, 'currentUserCanManageSettings'],
@@ -57,7 +57,8 @@
);
}
- public static function schema(): array
+ /** Registration uses stable types; execution validates current native choices. */
+ public static function schema(bool $registration = false): array
{
$properties = [
'append_to_content' => ['type' => 'boolean', 'default' => true, 'title' => __('Show Author Box below content', 'publishpress-authors')],
@@ -100,10 +101,16 @@
}
foreach (['post_types', 'author_page_post_types'] as $key) {
$fields = [];
- foreach (array_keys(Factory::getLegacyPlugin()->multiple_authors->get_all_post_types()) as $postType) {
+ // Abilities can be registered before the legacy modules load (init priority 1000), when another
+ // plugin starts the Abilities API registry early. get_all_post_types() needs no module state.
+ $module = Factory::getLegacyPlugin()->multiple_authors ?? new MultipleAuthorsClassesLegacyModule();
+ foreach ($registration ? [] : array_keys($module->get_all_post_types()) as $postType) {
$fields[$postType] = ['type' => 'boolean'];
}
$properties[$key] = Registry::object($fields);
+ if ($registration) {
+ $properties[$key]['additionalProperties'] = ['type' => 'boolean'];
+ }
}
foreach (['mapped_author_roles', 'author_for_new_users'] as $key) {
$properties[$key] = ['type' => 'array', 'maxItems' => 100, 'uniqueItems' => true,
@@ -153,7 +160,9 @@
} elseif ($field['type'] === 'array') {
$value = self::availableRoleValues($value, $field);
} elseif ($field['type'] === 'object') {
- $value = (object) array_map(static function ($enabled) { return $enabled === 'on'; }, (array) $value);
+ $value = (object) array_map(static function ($enabled) {
+ return $enabled === 'on';
+ }, (array) $value);
}
if ($key === 'author_page_post_types' && !(array) $value) {
$value = (object) ['post' => true];
@@ -161,6 +170,19 @@
$field['default'] = $value;
}
unset($field);
+ if ($registration) {
+ // Choices may be registered later on init; the live schema remains authoritative.
+ foreach ($properties as $name => &$field) {
+ if (in_array($name, ['author_pages_title_header', 'author_post_title_header', 'display_name_format'], true)) {
+ continue;
+ }
+ unset($field['enum']);
+ if (isset($field['items'])) {
+ unset($field['items']['enum']);
+ }
+ }
+ unset($field);
+ }
return Registry::object($properties);
}
@@ -217,10 +239,12 @@
$values = $current;
foreach ($input['settings'] as $name => $value) {
$type = $schema['properties'][$name]['type'];
- if (($type === 'boolean' && !is_bool($value)) || ($type === 'integer' && !is_int($value))
+ if (
+ ($type === 'boolean' && !is_bool($value)) || ($type === 'integer' && !is_int($value))
|| ($type === 'string' && !is_string($value))
|| (is_array($type) && !is_int($value) && $value !== '')
- || ($type === 'array' && (!is_array($value) || ($value && array_keys($value) !== range(0, count($value) - 1))))) {
+ || ($type === 'array' && (!is_array($value) || ($value && array_keys($value) !== range(0, count($value) - 1))))
+ ) {
return Registry::error(__('Use exact setting types from discovery.', 'publishpress-authors'));
}
if ($type === 'array') {
--- a/publishpress-authors/src/modules/author-boxes/author-boxes.php
+++ b/publishpress-authors/src/modules/author-boxes/author-boxes.php
@@ -326,16 +326,16 @@
if (is_array($baseline_data) && array_key_exists($key, $baseline_data)) {
$baseline_value = $baseline_data[$key];
$latest_value = array_key_exists($key, $latest_data) ? $latest_data[$key] : '';
- $client_changed = $this->normalizeAuthorBoxFieldValue($value)
- !== $this->normalizeAuthorBoxFieldValue($baseline_value);
- $server_changed = $this->normalizeAuthorBoxFieldValue($latest_value)
- !== $this->normalizeAuthorBoxFieldValue($baseline_value);
+ $client_changed = $this->normalizeAuthorBoxFieldValue($value, $args)
+ !== $this->normalizeAuthorBoxFieldValue($baseline_value, $args);
+ $server_changed = $this->normalizeAuthorBoxFieldValue($latest_value, $args)
+ !== $this->normalizeAuthorBoxFieldValue($baseline_value, $args);
if (!$client_changed) {
$value = $latest_value;
} elseif ($server_changed
- && $this->normalizeAuthorBoxFieldValue($value)
- !== $this->normalizeAuthorBoxFieldValue($latest_value)
+ && $this->normalizeAuthorBoxFieldValue($value, $args)
+ !== $this->normalizeAuthorBoxFieldValue($latest_value, $args)
) {
$value = $latest_value;
$conflicts[] = $key;
@@ -373,10 +373,22 @@
* integers or booleans after their field sanitizers have run.
*
* @param mixed $value Field value.
+ * @param array $args Field definition.
*
* @return mixed
*/
- protected function normalizeAuthorBoxFieldValue($value) {
+ protected function normalizeAuthorBoxFieldValue($value, $args = []) {
+ // A single-select displays its first option when the stored value has no matching option.
+ // Compare that effective value with the browser baseline, rather than flagging an empty
+ // or obsolete stored value as a concurrent edit.
+ if (isset($args['type']) && $args['type'] === 'select'
+ && !empty($args['options']) && is_array($args['options'])
+ && !is_array($value) && !is_object($value)
+ && !array_key_exists((string) $value, $args['options'])
+ ) {
+ $value = array_key_first($args['options']);
+ }
+
if (is_array($value)) {
foreach ($value as $key => $item) {
$value[$key] = $this->normalizeAuthorBoxFieldValue($item);
--- a/publishpress-authors/src/modules/author-categories/author-categories.php
+++ b/publishpress-authors/src/modules/author-categories/author-categories.php
@@ -512,6 +512,16 @@
if (!current_user_can(apply_filters('pp_multiple_authors_manage_categories_cap', 'ppma_manage_author_categories'))) {
return false;
}
+ return $this->insertAuthorCategory($insert_args);
+ }
+
+ /**
+ * Insert a category after authorization, or during internal installation.
+ *
+ * @param array $insert_args
+ * @return array|bool
+ */
+ private function insertAuthorCategory($insert_args) {
global $wpdb;
$table_name = AuthorCategoriesSchema::tableName();
@@ -857,7 +867,7 @@
];
foreach ($default_categories as $default_category) {
- $this->addAuthorCategory($default_category);
+ $this->insertAuthorCategory($default_category);
}
}
@@ -917,6 +927,14 @@
update_option('ppma_author_categories_meta_installed', 1);
}
+ // Older installers marked setup complete even when the permission check rejected every default.
+ // Repair only empty installations; leave existing category sets untouched.
+ if (version_compare($currentVersion, '4.20.1', '<')
+ && !get_ppma_author_categories(['count_only' => true, 'no_cache' => true])
+ ) {
+ $this->insertDefaultCategories();
+ }
+
if (empty(get_option('ppma_author_categories_cap_upgrade'))) {
$capability_roles = ['editor', 'author', 'contributor'];
foreach ($capability_roles as $capability_role) {