aljawaid / ContentCleaner

This tool allows admins to cleanup their Kanboard database by selectively deleting useless data saved by Kanboard and leftover data after uninstalling plugins.
MIT License
5 stars 1 forks source link

Internal Error: Invalid identifier: TYPE #24

Open DevPM99 opened 10 months ago

DevPM99 commented 10 months ago

After installation with the latest KB and PHP on a clean Windows Server IIS, I get this error when calling the plugin: "Internal Error: Invalid identifier: TYPE" on a blank web page. Nothing else. What am I missing/doing wrong?

aljawaid commented 10 months ago

Hi what version php? What database? Did you install the plugin from github or the directory in KB?

aljawaid commented 10 months ago

This could be related to #21

Possible Fix

Change TYPE to type:

https://github.com/aljawaid/ContentCleaner/blob/0204c4a86b181c18a1e49f3c425296474b2fe8a2/Model/ApplicationCleaningModel.php#L31

DevPM99 commented 10 months ago

Thanks. Renaming “TYPE” to “type” helps. However the next issue is:

“PHP Fatal error:  Namespace declaration statement has to be the very first statement or after any declare call in the script in C:\inetpub\wwwroot\WWWKanbanBoard\kanboard\plugins\ContentCleaner\Model\ApplicationCleaningModel.php on line 3
”

I’m really confused about the “plugin” / “plugins” folder mix-up.

The config says:

// Plugins directory define('PLUGINS_DIR', DIR.DIRECTORY_SEPARATOR.'plugins'); <= PLURAL “s”

But all plugins have this in their PHP files: “plugin” SINGULAR Like: “namespace Kanboard\Plugin\ContentCleaner\Model;”

What’s correct? Thanks

aljawaid commented 10 months ago

@DevPM99 Which version PHP are you using?

aljawaid commented 10 months ago

@DevPM99 In the directory, the folder is named as plugins which is correct.

In every file associated with a plugin, the text is written as plugin as the function and code is related to a single plugin.

DevPM99 commented 10 months ago

it is runnin on: Windows Server 2019 PHP Version 8.2.11 Kanboard Master Zip V 1.2.33 No specific configuration so far. Do I need to enable special PHP plugins?

aljawaid commented 10 months ago

Do I need to enable special PHP plugins?

Try KanboardSupport (latest release v4.5, not master) to see if any php issues flag up

DevPM99 commented 10 months ago

Call to undefined function Kanboard\Plugin\KanboardSupport\Helper\posix_getpwuid() in ...WWWKanbanBoard\kanboard\plugins\KanboardSupport\Helper\SupportHelper.php:267

DevPM99 commented 10 months ago

after skipping the not available posix function I get: PHP Warning: Undefined array key "script_uri" in ...\KanboardSupport\Template\config_sections\user-config.php on line 38 PHP Warning: Undefined array key "SERVER_ADDR" in ...KanboardSupport\Template\config_sections\server-config.php on line 31 PHP Warning: Undefined array key "SERVER_ADDR" in ...KanboardSupport\Template\config_sections\server-config.php on line 39 PHP Warning: Undefined array key "HTTP_MOD_REWRITE" in ...KanboardSupport\Template\config_sections\server-config.php on line 161

aljawaid commented 10 months ago

hmmm... I will look into these issues but it will take time. I'm thinking its because of Windows Server or php8.2... as all my plugins are only tested on linux ubuntu and php 7.4/8.1

DevPM99 commented 10 months ago

Before I switch to php 7.4 I suggest you look over your code for all posix and other linux functions and make them Windows compatible: https://stackoverflow.com/questions/2197366/how-to-install-posix-in-php My php skills are too low to check your code, sorry...

Your pluginmanager works, so I think it is not php but posix functions and upper/lower case issues in the database

f8ttyc8t commented 5 months ago

Using PHP 8.2.5, I've replaced 'TYPE' by 'type' in lines #31 and #70 of file ApplicationCleaningModel.php (plugin version 1.0.0) and it seems to work. Anyway, I'm not sure the result is correct, because I'm getting a suspicious number of tables to be cleaned up.

Screenshot from 2024-03-31 11-00-14

DevPM99 commented 5 months ago

After solving the „TYPE“ issue I get PHP Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in C:\inetpub\wwwroot\WWWKanbanBoard\kanboard\plugins\ContentCleaner\Model\ApplicationCleaningModel.php on line 3

However, the path seems to be identical to other plugins... No idea what's going wrong!

DevPM99 commented 5 months ago

I think it's still the Windows / POSIX commands issue.

f8ttyc8t commented 3 months ago

Using PHP 8.2.5, I've replaced 'TYPE' by 'type' in lines #31 and #70 of file ApplicationCleaningModel.php (plugin version 1.0.0) and it seems to work. Anyway, I'm not sure the result is correct, because I'm getting a suspicious number of tables to be cleaned up.

Screenshot from 2024-03-31 11-00-14

Btw. my instance is/was running on Debian 11, so not sure about Windows/POSIX command issue.

kuhytitusdlz commented 1 month ago

I have the same error TYPE on docker with sqlite db

atlasveldine commented 1 month ago

This occurs even in Docker with a brand new setup and nothing besides those three plugins installed.

Replicate easily by running latest docker image for kanboard, install Plugin Manager, ContentCleaner, and KanboardSupport.

KanboardSupport throws an error Warning: Undefined array key "SCRIPT_URI" in /var/www/app/plugins/KanboardSupport/Template/config_sections/user-config.php on line 38 in the Current Page.

ContentCleaner throws Internal Error: Invalid identifier: TYPE and refuses to display anything else.

I don't think this is related to Windows, given that the issue occurs even within Docker. I also tried running the image without named volumes for the data/plugins directories just to rule that out and it still has the same issues. That said, I am using a Windows host machine for Docker (WSL2 backend) so I guess it's possible, I'm not horribly familiar with the intricacies of Docker.