Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 1254 - php-4.1.2-r3 with IMAP doesn't work with uw-imap
Summary: php-4.1.2-r3 with IMAP doesn't work with uw-imap
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Jared H. Hudson
URL:
Whiteboard:
Keywords:
: 1352 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-20 02:09 UTC by Jared H. Hudson
Modified: 2003-02-04 19:42 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared H. Hudson 2002-03-20 02:09:08 UTC
There is two problems:

1st. The php-4.1.2-r3 ebuild has a bug in it
2nd. The php-4.1.2.orig/ext/imap/php_imap.h has a bug in it when used with
gentoo's uw-imap package.

-------------
1st. The php-4.1.2-r3 ebuild has a bug in it
-------------
If you look at the following section of the ebuild:

        if [ "`use imap`" ] ; then
                # need to see if imap was built w/ ssl support
                local pkg=`tail -n 1 /var/db/pkg/virtual/imapUW/VIRTUAL`
                if [ "`grep ssl /var/db/pkg/${pkg}/USE`" ] ; then
                        echo "imap compiled with SSL"
                        myconf="$myconf --with-imap-ssl"
                else
                        echo "imap compiled w/o SSL"
                        myconf="$myconf --with-imap"
                        # php build will fail if imap doesn't have SSL support
                        echo "unfortunately, the php build will fail due to"
                        echo "strange header errors in /usr/include/imap4r1.h"
                        echo "Please rebuild uw-imap or pine w/ 'ssl' in USE"
                        die
                fi
        fi

Presumedly, this "if SSL" statement was added because otherwise Apache would
complain of a undefined rfc822_parse_msg function, after adding this if
statement and forcing (through using die) the user to use the SSL version of
uw-imap/pine, PHP and Apache no longer gave this fatal message.
The reason why has nothing to do with SSL, it's because IMAP was NOT being
compiled into PHP.

If you look at the configure script that comes with PHP you will see that in
order to enable IMAP support you need to do a ./configure --with-imap
to enable IMAP w/SSL support you need to do a ./configure --with-imap
--with-imap-ssl
But, if you look at the section of the php-4.1.2-r3 ebuild above you will see
that it only does a --with-imap-ssl when SSL support is chosen and therefore
configure silently ignores it and does not compile in IMAP support.

So, the solution to the 1st problem is to say something like:
        if [ "`use imap`" ] ; then
                # need to see if imap was built w/ ssl support
                local pkg=`tail -n 1 /var/db/pkg/virtual/imapUW/VIRTUAL`
                if [ "`grep ssl /var/db/pkg/${pkg}/USE`" ] ; then
                        echo "imap compiled with SSL"
                        myconf="$myconf --with-imap --with-imap-ssl"
                else
                        echo "imap compiled w/o SSL"
                        myconf="$myconf --with-imap"
                fi
        fi

You will notice though, that know that you are actually compiling in IMAP
support into PHP with or without SSL you will still get the rfc822_parse_msg
error when you try to start Apache. That's because this error has nothing to do
with SSL, which brings me to my 2nd problem.

---------------
2nd. The php-4.1.2.orig/ext/imap/php_imap.h has a bug in it when used with
gentoo's uw-imap package.
---------------
In short, if you look at this file on line 40 you will notice a #ifdef that
looks for what version of the IMAP library you have, if you have the latest as
defined my HAVE_IMAP2000 or HAVE_IMAP2001 it includes c-client.h and imap4r1.h
otherwise mail.h and rfc822.h. In the comments it says that c-client.h will
include mail.h and rfc822.h. Well, a simple grep include /usr/include/c-client.h
will quickly show that this is FALSE. At least with the UW-IMAP that Gentoo
includes. Perhaps this use to be true a couple of imap versions ago, but either
way it's false now.

So, the reason why you get the rfc822_parse_msg undefined error is that it's
defined in rfc822.h (imagine that!) which is not included by PHP.

So the following patch fixes the file:

diff -u -r php-4.1.2.orig/ext/imap/php_imap.h php-4.1.2/ext/imap/php_imap.h
--- php-4.1.2.orig/ext/imap/php_imap.h	Thu Aug 16 15:21:31 2001
+++ php-4.1.2/ext/imap/php_imap.h	Wed Mar 20 00:02:30 2002
@@ -43,8 +43,8 @@
  #include "imap4r1.h"	/* location of c-client quota functions */
 #else
  #include "mail.h"
- #include "rfc822.h" 
 #endif
+#include "rfc822.h"
 
 extern zend_module_entry imap_module_entry;
 #define imap_module_ptr &imap_module_entry

------------------
So, in short, remove the die/warning from the ebuild thus allowing people to
compile imap support into php with or without SSL. Fix the SSL part so it
includes the --with-imap statement.
Add to the unpack() section of the ebuild a patch statement and the patch above.

That's it!
Comment 1 Grant Goodyear (RETIRED) gentoo-dev 2002-04-01 11:19:05 UTC
*** Bug 1352 has been marked as a duplicate of this bug. ***
Comment 2 Todd Wright 2002-04-07 01:27:52 UTC
I too had this bug - I found the 2nd comment incorrect for my version of uw-
imap-2001a which downloaded with gentoo 1.0 - this version does include 
rfc822.h from c-client.h

What I found is that not all imap header files were copied to /usr/include and 
I had to manually copy them for PHP to compile. They should be copied as part 
of the uw-imap install to /usr/include/imap as there are many headers, and htis 
path should be added to the -I CFLAGS parms

Basically, the relationship between apache/php/uw-imap/ssl needs to be re-
examined and fixed properly.
Comment 3 Todd Wright 2002-04-13 00:21:42 UTC
Wondering if anyone reads these bug reports. There have been 2 reviosions to 
the php ebuild since r3 (its now up to r5) and this has not been addressed.
Comment 4 Jared H. Hudson 2002-04-15 16:43:10 UTC
Fixed in php-4.1.2-r7 with uw-imap-2001a-r1