Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

[PHP] Optimizing multiple I/O operations and catching errors

  • 19-09-2010 10:54pm
    #1
    Registered Users Posts: 18


    Hi
    I am working on an upload system in php.
    Rather than try to explain it in english I'll just stick some pseudocode in here :o
    [PHP]
    input image (uploaded .jpg)
    input archive (uploaded .zip)

    if(validate input) {
    if(resize image and extract archive) {
    foreach(extacted file) {
    compare to array
    } else {handle resize/extract error}

    if(comparison to array ok) {
    if(insert to database ok) {
    if(update extracted file with auto increment id from db ok) {
    if(repackage zip ok) {
    if(post to phpbb ok) {
    if(update db with phpbb post id) {

    Everything went fine, proceed to next page

    } else {handle update db error}
    } else {handle post error}
    } else {handle repackage error}
    } else {handle update file error}
    } else {handle database error}
    } else {handle comparison error}
    } else {handle input error}
    [/PHP]

    Ok so hopefully you get the idea, the upload process only succeeds if every if(operation) succeeds.
    On to my question: Is there a 'better' way to handle errors during processing? The if() operations all return false if any error occurs during the sub operation. I've considered exceptions but because every operation relies on user input, any errors would be expected rather than exceptional.

    Error handling amounts to "set error=description of error, delete uploaded files, redisplay form with entered information"

    Memory/CPU usage are not an issue and the upload system shouldn't be getting much usage but if pushed how would you optimize this?

    Thanks for your time guys :)


Advertisement