• I Read The Comments (unregistered)

    private function isCorrectFileName($fileName) { $fileName = strtolower($fileName); $suffix = $this->getMessageNumberForAttachmentFilename() . $this->getAttachmentSuffix(); $suffixLocation = strpos($fileName, $suffix); if ($suffixLocation !== false) { $fileName = str_replace($suffix, '', $fileName); $fileName = str_replace($this->getAttachmentPrefix(), '', $fileName); if (is_numeric($fileName) && ($fileName == 0)) return true; } return FileNotFound; }

  • Robin (unregistered)

    It actually took me a while - including rereading the introduction - to realise WHY this would fail for message IDs greater than 999. And then having seen why it did - wow, whoever coded this obviously knew this wouldn't work for numbers past 1000. Or at least knew they were relying on there always being a 0 before the number in the filename, and didn't think to look up, or ask anyone, where this was coming from. So I'm not sure whether this is a case of

    1. developer simply putting in something which appears to work for reasons they don't understand, and accepting it
    2. developer knowing it would break later, but writing it anyway without even so much as an explanatory comment like // TODO: ensure this handles ids over 999

    Probably 1) is much more likely, but whichever it is, that's TRRRRRWTF.

  • ZZartin (unregistered)

    It's generic and will work on any system, assuming they use a very specific format for their file names.

  • coca cola original recipe (unregistered)

    Run inotify on the directory. Log stale files and notify.

  • markm (unregistered) in reply to Robin

    Instead of specifications you get a set of, say, 150, sample files "msg0000.wav" through "msg0149.wav". The message number begins with "0" in all the samples. So do you assume it always begins with zero, or that it's always four digits?

    That depends on whether or not you are an idiot.

  • bob wildcat (unregistered)

    The real WTF here is that you can enable email notifications directly in Asterisk

    https://github.com/asterisk/asterisk/blob/master/configs/samples/voicemail.conf.sample

  • Nuitari (unregistered)

    Why not just use the builtin asterisk feature of emailing the voicemail in the first place?

  • löchleindeluxe (unregistered)

    Chaotic neutral bugfix: replace the filename prefix with '0' instead.

    Chaotic evil bugfix: just remove the is_numeric, won't PHP autocast string to int if you have the arguments the right way around? And I doubt '' wouldn't cast to 0 there. I can totally see this being an error that was introduced during a code review/cleanup by somebody else who just saw "oh, it's casting to int and doesn't run is_numeric first, that's got to be wrong".

  • (nodebb)
    Comment held for moderation.

Leave a comment on “Voicemail to Email to Nothing at All”

Log In or post as a guest

Replying to comment #538413:

« Return to Article