Skip to content
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

[3.0]: add $possible_topic_columns to integrate_modify_post #8318

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

live627
Copy link
Contributor

@live627 live627 commented Oct 7, 2024

Motivation

I have a modification (Topic Descriptions) that adds a column to smf_topics. Currently, a separate query is necessary to update the topics table. This commit allows for adding the new column to the existing query.

Description

  1. Introduction of $possible_topic_columns:

    • A new associative array, $possible_topic_columns, is added to map topic option keys (e.g., sticky_mode, lock_mode, poll) to their corresponding database column names and data types.
    • This replaces hardcoded column and parameter assignments for topic modifications.
  2. Enhancements to the integrate_modify_post Hook:

    • The integrate_modify_post hook now includes the new $possible_topic_columns array, enabling mods to interact with these columns more effectively.

The $possible_topic_columns array introduced in the patch is an associative array. Its structure is as follows:

$possible_topic_columns = [
    'key_in_topicOptions' => ['type' => 'db_column_name'],
];

Example from the Patch

$possible_topic_columns = [
    'sticky_mode' => ['int' => 'is_sticky'], // Maps 'sticky_mode' from $topicOptions to the 'is_sticky' database column with type 'int'.
    'lock_mode'   => ['int' => 'locked'],   // Maps 'lock_mode' from $topicOptions to the 'locked' database column with type 'int'.
    'poll'        => ['int' => 'id_poll'],  // Maps 'poll' from $topicOptions to the 'id_poll' database column with type 'int'.
];

Details:

  1. Keys ('sticky_mode', 'lock_mode', 'poll'):

    • These are the keys expected in the $topicOptions array, passed as input to the function.
  2. Values:

    • The value is an array where:
      • The first element is the data type ('int', 'string', etc.) for parameter binding in the query.
      • The second element is the database column name ('is_sticky', 'locked', 'id_poll').

@live627 live627 added the Hooks label Oct 7, 2024
@live627 live627 changed the title add $possible_topic_columns to integrate_modify_post [3.0]: add $possible_topic_columns to integrate_modify_post Oct 7, 2024
@live627
Copy link
Contributor Author

live627 commented Nov 11, 2024

request for comment @jdarwood007 @Sesquipedalian or should I merge this as-is

@Sesquipedalian
Copy link
Member

Sorry, I'm still on hiatus so I haven't had a chance to look at this. Can you add a description for the PR so that we know what it intends to accomplish?

@live627
Copy link
Contributor Author

live627 commented Nov 28, 2024

summady added courtesy of chat gpt

@Sesquipedalian
Copy link
Member

Thanks, but I wasn't really asking for a description of what this PR changes. I was asking why you want to make these changes. What's the goal? What do these changes make possible?

@live627
Copy link
Contributor Author

live627 commented Nov 29, 2024

I have a modification (Topic Descriptions) that adds a column to smf_topics. Currently, a separate query is necessary to update the topics table. This commit allows for adding the new column to the existing query.

@Sesquipedalian
Copy link
Member

Ah. That makes sense. Thanks. I will review this as soon as I can.

@Sesquipedalian Sesquipedalian merged commit 5a3114e into SimpleMachines:release-3.0 Dec 18, 2024
6 checks passed
@live627 live627 deleted the modify branch December 19, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants