Geeklog-Core / geeklog

Geeklog - The Secure CMS.
https://www.geeklog.net
25 stars 19 forks source link

Geeklog Moderation not displaying Edit Link #1117

Closed eSilverStrike closed 2 years ago

eSilverStrike commented 2 years ago

Shows just the id in the edit column but not the edit link for any submission item type.

eSilverStrike commented 2 years ago

@mystralkk wow this was a little hard to crack as it was a weird one. Simple fix but took a while to figure out why things where happening the way they were.

I stepped through the moderation itemlist function along with ADMIN_simpleList and ADMIN_getListField_moderation and couldn't figure out why it was working on Geeklog.net but not on my dev site. I then thought maybe some code changes was at work here creating the bug from Geeklog 2.2.1 and 2.2.2 but that wasn't it.

Looking closer at the code I then couldn't figure out why it was actually working on Geeklog.net (and Geeklog version 2.2.1)

In ADMIN_getListField_moderation the fieldname should never had matched the case statement for 'edit' as 0 was being sent but for some reason it was.

I then changed the PHP version of my dev server from 8 to 7.4 and it worked.

I ended up finding this PHP bug report:

https://bugs.php.net/bug.php?id=80490

You are using switch statement which performs loose comparison. Up to PHP 7.4 the type system was treating 0 == 'a'. Since PHP 8 the type system and loose comparisons have been improved.

which was what was happening. Looks like a bug has been in the Geeklog moderation code all along and just the way the switch and case statement was setup with 'edit' being first it ended up working.

Anyways was kind of interesting in a frustrating sort of way :-)

It is now fixed.

mystralkk commented 2 years ago

I guess there might be a lot of potential bugs like this, since Geeklog saves boolean values as an integer (1 / 0), and retrieves them as a string ('1' / '0').