Problem/Motivation

I see that the module follows very old PHP standard practices, for example it doesn't follow the function return type hinting, among other features that need to be added

More information about Drupal's coding standards

Steps to reproduce

Look into the module's source code, it is using outdated PHP practices.

Proposed resolution

Upgrade the module follow recent standard practices for writing more robust PHP code.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork gifplayer-3581172

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

danrod created an issue. See original summary.

danrod’s picture

Issue tags: +Novice
yusuf_khan’s picture

Assigned: Unassigned » yusuf_khan

working on it

yusuf_khan’s picture

Status: Active » Needs review
yusuf_khan’s picture

Assigned: yusuf_khan » Unassigned
vinodhini.e’s picture

Hi,

Tested this on Drupal 10.5.1 and ran coding standards using PHPCS, Stylelint, and ESLint.

After applying MR !20 and re-running the reports, no issues are reported. Everything is working fine.

Thanks.

danrod’s picture

Status: Needs review » Needs work

There are some PHPSTAN issues to fix and the tests doesn't seem to be working

yusuf_khan’s picture

Status: Needs work » Needs review

https://git.drupalcode.org/project/gifplayer/-/merge_requests/20 - @danrod PHPSTAN issues has been fixed.Please review

danrod’s picture

StatusFileSize
new35.72 KB

Hi @yusuf_khan did you test the functionality at all? I reviewed the functionality and it is not working at all now (please see attachment). Please review your code and make sure that the gif actually loads.

danrod’s picture

Status: Needs review » Needs work
yusuf_khan’s picture

@danrod i will fix the issue

jerech made their first commit to this issue’s fork.

jerech’s picture

Status: Needs work » Needs review
danrod’s picture

Hi @jeremy1606 did you test your changes as well? I'm getting this error when loading a page with a gif:

The website encountered an unexpected error. Try again later.

Drupal\Core\File\Exception\InvalidStreamWrapperException: in Drupal\Core\File\FileUrlGenerator->doGenerateString() (line 106 of core/lib/Drupal/Core/File/FileUrlGenerator.php).
Drupal\Core\File\FileUrlGenerator->generateAbsoluteString() (Line: 284)
Drupal\gifplayer\Plugin\Field\FieldFormatter\GifPlayerFormatter->viewElements() (Line: 91)
Drupal\Core\Field\FormatterBase->view() (Line: 83)
Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view() (Line: 275)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 341)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 29)
Drupal\node\NodeViewBuilder->buildComponents() (Line: 283)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 240)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 107)

I'm guessing the error is triggered from the line 284 at src/Plugin/Field/FieldFormatter/GifPlayerFormatter.php :

$img_cover = $this->fileUrlGenerator->generateAbsoluteString('base://' . $this->extensionListModule->getPath('gifplayer') . '/img/banana.png');
danrod’s picture

Status: Needs review » Needs work
jerech’s picture

Status: Needs work » Needs review

I've tried to fix the error. Could you check it again? Thank you very much.

danrod’s picture

StatusFileSize
new73.03 KB

Thanks @jerech the WSOD is gone, I can see the banana.png file, but still unable to see the GIF at all, setting this to "Needs Work" again. I'll find some time to fix this later this week (screenshot attached)

danrod’s picture

Status: Needs review » Needs work
yusuf_khan’s picture

Status: Needs work » Needs review

Updated MR !20 with a fix for the GifPlayer JavaScript initialization.

The previous behavior used `TRUE` in JavaScript, which caused a ReferenceError and prevented the gifplayer plugin from initializing. I replaced the global initialized flag with Drupal's `once()` API and added the required `core/once` library dependency.

Tested locally on Drupal 11.3.3:
- Created an Article with a Gif Player Icon field.
- Confirmed the formatter renders the banana cover and valid `data-gif` URL.
- Confirmed the uploaded GIF loads after clicking the player.
- Ran PHPCS with Drupal and DrupalPractice standards.
- Ran `node --check js/gif-player.js`.

@danrod Please review.

danrod’s picture

Hi @yusuf_khan , thanks a lot, I tested your changes and it is working as expected, I also reviewed your code changes and found no issues. I'll merge this.

danrod’s picture

Status: Needs review » Reviewed & tested by the community
danrod’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

danrod’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.