Topic: Problems after using PHP 5.2.10 rpms in repo

After using your RPMs to upgrade to PHP 5.2.10 (and after having to solve some zend heap problem do the an infinite loop caused by this problem), I now have this error on my website:

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/fedtrek.com/httpdocs/mainfile.php on line 1233
Warning: fsockopen() [function.fsockopen]: unable to connect to www.fedtrek.com:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /var/www/vhosts/fedtrek.com/httpdocs/mainfile.php on line 1233

Everything was fine before upgrading. If it helps, this is the block of code where the problem occcures:

function headlines($bid, $cenbox=0) {
    global $prefix, $db;
    $bid = intval($bid);
    global $cache;
    $data = $cache->array_load_check_remove('block_'.$bid, 'blocks', 300);
    if ($data === false)
    {
        $result = $db->sql_query("SELECT title, content, url, refresh, time FROM ".$prefix."_blocks WHERE bid='$bid'", false, __LINE__, __FILE__, false);
        list($title, $content, $url, $refresh, $otime) = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $title = filter($title, "nohtml");
        $content = filter($content);
        $url = filter($url, "nohtml");
        $refresh = intval($refresh);
        $otime = intval($otime);
        $past = time()-$refresh;
        $cont = 0;
        if ($otime < $past OR empty($content)) {
            $btime = time();
            $rdf = parse_url($url);
            $fp = false;
            //while (!$fp)
            {
                $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
                $content = "";
                $array = array(
                    'content' => &$content,
                    'time' => &$btime,
                );
            }
            if (!$fp) {
                $content = "";
                //$cache->array_save('block_'.$bid, 'blocks', array('title' => $title, 'content' => $content));
                // deleted by omega13a (Jan 20, 2009)
                //$db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'", false, __LINE__, __FILE__, true, __FUNCTION__, __CLASS__);
                // added by omega13a (Jan 20, 2009)
                $db->sql_query("UPDATE ".$prefix."_blocks SET ".$db->sql_fields('update', $array)." WHERE bid='$bid'", false, __LINE__, __FILE__, true);
                // end mod
                $cont = 0;
                if ($cenbox == 0) {
                    themesidebox($title, $content);
                } else {
                    themecenterbox($title, $content);
                }
                trigger_error(_RSSPROBLEM, E_USER_WARNING);
                return;
            }
            if ($fp) {
                if (!empty($rdf['query']))
                $rdf['query'] = "?" . $rdf['query'];

                fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
                fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
                $string    = "";
                while(!feof($fp)) {
                    $pagetext = fgets($fp,300);
                    $string .= chop($pagetext);
                }
                fputs($fp,"Connection: close\r\n\r\n");
                fclose($fp);
                $items = explode("</item>",$string);
                $content = "<font class=\"content\">";
                for ($i=0;$i<10;$i++) {
                    $link = ereg_replace(".*<link>","",$items[$i]);
                    $link = ereg_replace("</link>.*","",$link);
                    $title2 = ereg_replace(".*<title>","",$items[$i]);
                    $title2 = ereg_replace("</title>.*","",$title2);
                    $title2 = stripslashes($title2);
                    if (empty($items[$i]) AND $cont != 1) {
                        $content = "";
                        // deleted by omega13a (Jan 20, 2009)
                        //$db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'", false, __LINE__, __FILE__, true, __FUNCTION__, __CLASS__);
                        // added by omega13a (Jan 20, 2009)
                        $db->sql_query("UPDATE ".$prefix."_blocks SET ".$db->sql_fields('update', $array)." WHERE bid='$bid'", false, __LINE__, __FILE__, true);
                        // end mod
                        $cont = 0;
                        $cache->array_save('block_'.$bid, 'blocks', array('title' => $title, 'content' => $content));
                        if ($cenbox == 0) {
                            themesidebox($title, $content);
                        } else {
                            themecenterbox($title, $content);
                        }
                        return;
                    } else {
                        if (strcmp($link,$title2) AND !empty($items[$i])) {
                            $cont = 1;
                            $content .= "<strong><big>&middot;</big></strong><a href=\"$link\" target=\"new\">$title2</a><br>\n";
                        }
                    }
                }

            }
            // deleted by omega13a (Jan 20, 2009)
            //$db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'", false, __LINE__, __FILE__, true, __FUNCTION__, __CLASS__);
            // added by omega13a (Jan 20, 2009)
            $db->sql_query("UPDATE ".$prefix."_blocks SET ".$db->sql_fields('update', $array)." WHERE bid='$bid'", false, __LINE__, __FILE__, true);
            // end mod
        }
        $siteurl = str_replace("http://","",$url);
        $siteurl = explode("/",$siteurl);
        if (($cont == 1) OR (!empty($content))) {
            $content .= "<br><a href=\"http://$siteurl[0]\" target=\"blank\"><b>"._HREADMORE."</b></a></font>";
        } elseif (($cont == 0) OR (empty($content))) {
            $content = "<font class=\"content\">"._RSSPROBLEM."</font>";
        }
        $cache->array_save('block_'.$bid, 'blocks', array('title' => $title, 'content' => $content));
        if ($cenbox == 0) {
            themesidebox($title, $content);
        } else {
            themecenterbox($title, $content);
        }
    }
    else
    {
        $title = &$data['title'];
        $content = &$data['content'];
        if ($cenbox == 0) {
            themesidebox($title, $content);
        } else {
            themecenterbox($title, $content);
        }
    }
}

My website is heavily modified PHPNuke (a lot of custom tweaks I made myself). The server is running CentOS 5, Apache 2.2.3, and suPHP.

Fish need bicycles!
omega13a's Yum Repo

Re: Problems after using PHP 5.2.10 rpms in repo

> getaddrinfo failed

I've seen this error only in 2 situations :

1/ hostname can't be resolved, because of DNS issue.

Does "host www.fedtrek.com" succed ?

2/ apache is started "before" network connection fully established, especially when connected through NetworkManger

Does error occurs after a "service apache restart" ?

Despite this issue, this part seems really strange

while (!$fp) {
          $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
          ...
}

No other exit condition (max attempt, timeout, ...)
No pause between each attempt
A simple $pagetext = file_get_contents('http://www.fedtrek.com/'); seems really simpler (I know than fsockopen can't be use to go through a proxy, but this doesn't seems to be the case)

+

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Problems after using PHP 5.2.10 rpms in repo

Bonjour Remi,

J'ai vu ce post qui parle du problème de migration de version php. J'en profite poser le mien.

Mon environnement:
CentOS 5.4 avec php 5.1.6

Action :

Je souhaitais mettre à jour PHP 5.1.6 à 5.2. J'ai suivi vos instructions ci-dessous:
1 : Créer un fichier :

/etc/yum.repos.d/remi.repo

2 : Ajouter les textes ci-dessous:

********** BEGIN FILE**********************************
[remi]
name=Les RPM de remi $releasever - $basearch
baseurl=http://rpms.famillecollet.com/fedora/$releasever/remi/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
********** END FILE**********************************

3 : Avec yum, desistaller le paquet php 5.1.6

#yum remove php

4 : On reinstalle php 5.2.9

#yum install php

5 : Vérification de la version, et j'ai bien la bonne version

#yum info php
Available Packages
Name       : php
Arch       : i386
Version    : 5.2.9
Release    : 1.fc5.remi
Size       : 1.2 M
Repo       : remi

5 : redémarrer apache : service httpd restart

Mon problème
Lorsque j'invoque une page php, je vois le code source directement sur le navigateur.

Avez-vous une idée, d'ou pouvait venir ce problème ? Quel fichier à configurer ? Est-il nécessaire d'upgrader aussi apache ?

Je vous remercie par avance de votre collaboration.

Linx.

Re: Problems after using PHP 5.2.10 rpms in repo

1/ php 5.2.9 n'est plus dans le dépôt depuis longtemps, maintenant c'est les versions 5.3.x. Donc ça m"étonnerait que l'installation soit faite par yum.

2/ la page PHP passe bien par le serveur (url http://xxx et pas file:///xxx) ?

3/ le code utilise bien les tags <?php (les short-tags <? ne doivent plus être utilisés) ?

+

P.S. : effectivement j'avais pas noté... FC5 ! les dépôts ne sont plus mis à jour pour cette version ancestrale de Fedora, et c'est donc probablement le vieux PHP 5.2.9 qui traine dans le dépôt.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi