Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2014-06-23 00:24:14
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
File tab allows creation of blank file record
Steps to reproduce problem:
- Copy a file to the files directory
- Go to Files tab
- Click Create button WITHOUT selecting an existing file
Observations:
- new file record created with blank file name
- condition is allegedly OK!
- seen in 4.5.5 & latest SVN
This can’t be right … can it?
Offline
Re: File tab allows creation of blank file record
+1. Confirmed here on 4.5.5.
Offline
Re: File tab allows creation of blank file record
On it. And your other one. Good sleuthing, Sir.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: File tab allows creation of blank file record
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#5 2014-06-23 23:07:33
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: File tab allows creation of blank file record
Bloke wrote #281593:
Good sleuthing, Sir.
You flatter me … more a case of hacking around in the Files Tab & tripping over something in the dark.
Thanks for doing the honours … the red error message comes up as “Failed to upload file (db_add) “ – could this be made a bit more meaningful?
Offline
Re: File tab allows creation of blank file record
gomedia wrote #281599:
the red error message comes up as “Failed to upload file (db_add) “ – could this be made a bit more meaningful?
Yes and no. Yes if I could be arsed to write more lines of code tonight :-)
Since the file insertion happens in a function, the quick (*cough* lazy) way to trap it is to check if the filename’s empty in the function and return false. Of course that’s what I did. Thus it remains the domain of the calling environment to show the error message. Which it does: a generic, ugly, red message.
If I was to do it properly it should probably trap the empty filename issue earlier in every place it could occur (in the core it’s actually only from two places) and handle it separately at that point with a dedicated message. That wouldn’t help plugins who call the db_add function though. But then the function should be raising exceptions instead of returning false, so we’re painted into a corner until stuff like this is refactored properly.
Meh, I’ll probably just do the checks elsewhere and handle them separately. Was just being lazy, sorry. Maybe tomorrow though…
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline