Skip to content

A few code issues #5

@Dimasmagadan

Description

@Dimasmagadan

https://github.com/ddev-app/feditor/blob/9f7bc988e308f020d4e31c6cf8c6f3175a24fa80/feditor.php#L13
I'd suggest not to use glob and require_once in a loop, cause it can cause several issues:

  • Security: The directory contents are not verified, any malicious files can be included and potentially harm the system.
  • Performance: require_once is slower compared to other file inclusion methods and reading all files through a loop can slow down the application, especially if the directory has many files. Better to use autoloader or require with a conditional check like if_function_exists() inside
  • Maintainability: more files are longer to read and harder to maintain. But could be ok for a small project

https://github.com/ddev-app/feditor/blob/9f7bc988e308f020d4e31c6cf8c6f3175a24fa80/feditor.php#L35
An ob_start inside a WordPress shortcode could lead to a few issues:

  • it can cause unexpected behavior: If a shortcode starts an output buffer, any output generated by other plugins or themes that runs before the shortcode's buffer is flushed will be captured and discarded, leading to unexpected behavior.
  • Buffering can cause unexpected nesting: If multiple shortcodes start output buffers, the buffers can become nested, causing problems when trying to flush them in the correct order.
  • Buffering can cause memory leaks: Output buffering can cause memory leaks if the buffer is not properly flushed, causing the memory usage of the application to increase over time.

https://github.com/ddev-app/feditor/blob/9f7bc988e308f020d4e31c6cf8c6f3175a24fa80/feditor.php#L53
intval() would return 0 for empty value, no need to for an extra empty() check

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions