[#6625] imp/lib/SpellChecker/aspell.php test for ecode broken
Summary imp/lib/SpellChecker/aspell.php test for ecode broken
Queue IMP
Queue Version FRAMEWORK_3
Type Bug
State Resolved
Priority 1. Low
Owners Chuck Hagenbuch <chuck (at) horde (dot) org>
Requester liamr (at) umich (dot) edu
Created 04/18/2008 (29 days ago)
Due
Updated 04/21/2008 (26 days ago)
Assigned 04/18/2008 (29 days ago)
Resolved 04/21/2008 (26 days ago)
Attachments aspell.log Download
Milestone
Patch

History
04/21/2008 Chuck Hagenbuch State ⇒ Resolved
Assigned to Chuck Hagenbuch
 
04/21/2008 liamr (at) umich (dot) edu Comment #8 Reply to this comment
Seems like it works.  Thanks!
04/21/2008 Chuck Hagenbuch Comment #7 Reply to this comment
04/21/2008 liamr (at) umich (dot) edu Comment #6 Reply to this comment
I don't actually know any of the PHP developers, so I've tacked a comment onto one of the bugs I perceived to be applicable (and that was still allowing comments).  If one of you has an in with the folks at php.net, could you pursue this?

In the meantime, what about replacing...

        if (($ecode = proc_close($process)) != 0) {

with something like..

        if (strlen($out) == 0) {

or

        if (empty($out)) {

if there's a problem invoking aspell, $out stays empty, but $err gets filled.. so this seemed like it might work ok?
04/21/2008 Chuck Hagenbuch Comment #5 Reply to this comment
Well sure, that's what we're trying to do. What would you suggest? Maybe ask Ilia what people who _do_ use Oracle should do.
04/21/2008 liamr (at) umich (dot) edu Comment #4 Reply to this comment
I can't figure out the difference between our test and development environments re: this issue.

As mentioned in...
http://bugs.php.net/bug.php?id=29123

    [16 Jul 2004 1:32am UTC] iliaa@php.net

    When sigchild is used the return status from pclose and
    proc_close() cannot be retrieved.

And --enable-sigchild is strongly recommended for PHP users using Oracle.  So.. if oracle is going to remain supported, I really think you have to find another way to judge whether aspell is working than checking the exit code provided by proc_close()
04/18/2008 liamr (at) umich (dot) edu Comment #3 Reply to this comment
The code just makes it return 255 instead of -1 on the effected machine, which I've read might just be another way to say "-1". 

I'd like to know why it works (returns exit code 0) in our dev environment but not our test environment.. but I haven't figured that out yet.  In the meantime, if I rebuild php without --enable-sigchild, the problem seems to go away.  That can't be the answer, tho.
04/18/2008 Chuck Hagenbuch Comment #2
State ⇒ Feedback
Reply to this comment
Can you test if the:

$ret = (proc_close($proc) >> 8) & 0xff;

Trick works, and if it still works if you create a genuine failure? We can't just check for -1, since 0 _is_ being returned in other working PHP installs.
04/18/2008 liamr (at) umich (dot) edu Comment #1
New Attachment: aspell.log Download
Patch ⇒
Milestone ⇒
Queue ⇒ IMP
Summary ⇒ imp/lib/SpellChecker/aspell.php test for ecode broken
Type ⇒ Bug
Priority ⇒ 1. Low
State ⇒ Unconfirmed
Reply to this comment
per http://marc.info/?l=imp&m=120853832309748&w=2

I think I've tracked the issue down.  IMP is looking for aspell to exit with a code of "0" to decide whether the spellcheck works.

imp/lib/SpellChecker/aspell.php ~ ln 67:

        if (($ecode = proc_close($process)) != 0) {
            require_once 'PEAR.php';
            if ($this->_encoding) {
                $err = String::convertCharset($err, $this->_encoding, $charset);
            }
            return PEAR::raiseError('spellcheck failed: ' . $err, $ecode);
        }

proc_close() doesn't return results you think it's returning.  See...
  http://us2.php.net/manual/en/function.proc-close.php
  http://bugs.php.net/bug.php?id=17538

Apparently, it's especially faulty if you compiled php with --enable-sigchild, which you're told to do if you're trying to use oracle on linux.

The debugging stubs I placed in aspell.php clearly show that aspell is being invoked, and is returning the expected output.  If I change..

   proc_close($process)) != 0

to look for -1, spellchecking works just dandy.