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

fixed: code issues #499

Merged
merged 3 commits into from
Apr 15, 2024
Merged

Conversation

bhupeshappfoster
Copy link
Collaborator

Pull Request

Description:

Craft suggested to use php stan before upgrading to craft 5 support and resolve any issues found.

Related Issue(s):

[Cite any related issues or feature requests, using the GitHub issue link.]

Changes Made:

[List the changes made in this pull request to address the issue or implement the feature.]

Added:

Changed:

Deprecated:

Removed:

Fixed:

  • Issues suggested by phpstan.

Security:

Testing:

[Describe the testing performed to ensure the changes are functioning as expected.]

Quality Assurance (QA):

  • The code has been reviewed and approved by the QA team.
  • The changes have been tested on different environments (e.g., staging, production).
  • Integration tests have been performed to verify the interactions between components.
  • Performance tests have been conducted to ensure the changes do not impact system performance.
  • Any necessary database migrations or data transformations have been executed successfully.
  • Accessibility requirements have been considered and tested (e.g., screen reader compatibility, keyboard navigation).

Resources:

Screenshots (if applicable):
[Include any relevant screenshots to visually demonstrate the changes.]

Wrapping up

Checklist:

  • The code builds without any errors or warnings.
  • The code follows the project's coding conventions and style guidelines.
  • Unit tests have been added or updated to cover the changes made.
  • The documentation has been updated to reflect the changes (if applicable).
  • All new and existing tests pass successfully.
  • The PR has been reviewed by at least one other team member.

Additional Notes:
[Include any additional notes, considerations, or context that may be relevant.]

Comment on lines -68 to -101
public static function populateModel($attributes)
{
if ($attributes instanceof AssetDraftRecord) {
$attributes = $attributes->getAttributes();
}

$assetData = json_decode($attributes['data'], true);
$fieldContent = isset($assetData['fields']) ? $assetData['fields'] : null;
// $attributes['draftId'] = $attributes['id'];
$attributes['id'] = $attributes['assetId'];

$attributes = array_diff_key($attributes, array_flip(array('data', 'fields', 'assetId')));

$attributes = array_merge($attributes, $assetData);

$draft = parent::setAttributes($attributes);

if ($fieldContent) {
$post = array();

foreach ($fieldContent as $fieldId => $fieldValue) {
$field = Craft::$app->fields->getFieldById($fieldId);

if ($field) {
$post[$field->handle] = $fieldValue;
}
}

$draft->setFieldValues($post);
}

return $draft;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed due to not being in use.

@@ -73,39 +71,6 @@ public function getHandle()
return $this->getGlobalSet()->handle;
}

public static function populateModel($attributes)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in use

LinkField::class => LinkFieldTranslator::class,
TypedLinkField::class => TypedLinkFieldTranslator::class,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As link field plugin is one renamed to typed link field so removed old one.

case $value instanceof \fruitstudios\linkit\fields\LinkitField:
case $value instanceof \presseddigital\linkit\fields\LinkitField:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ownership of plugin was changed.

@bhupeshappfoster
Copy link
Collaborator Author

@sidedwards @shnsumit

The first step for craft 5 upgrade was to resolve issues in plugin code. So we did these changes to fix issues shown by phpstan and now the check is showing this
image

NOTE: I am doing extensive testing to confirm every thing is working as it was prior to these changes. Would be great to have a second pair of eyes too.

CC: @MerrittBoydston

@bhupeshappfoster
Copy link
Collaborator Author

bhupeshappfoster commented Apr 5, 2024

@bhupeshappfoster bhupeshappfoster merged commit f8f18c6 into BP/release3.4.0 Apr 15, 2024
@bhupeshappfoster bhupeshappfoster deleted the BP/PhpStan-code-correction branch April 15, 2024 13:36
bhupeshappfoster added a commit that referenced this pull request Jul 10, 2024
* fixed: code issues before upgrading to craft5 (#499)

* updated: change logs and version bumped

* Added: hyper link field support (#504)

* Bp/524/verbb navigation plugin support (#506)

* fixed: activity log table name issue (#505)

* fixed: navigration draft and pgsql migration issue

* updated: change log

* fixed: dashboard UI issue
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.

2 participants