Jump to content

Bizarre mod_fcgid related issue (500 Internal Server Error)


Recommended Posts

Hello everyone,

 

I'm having a bizarre issue which, according to the error log, is mod_fcgid related. After searching around about issues relating to this module, I can't find any help that matches my error message precisely.

The error message is;

 

[Wed Apr 11 16:24:55.958158 2012] [:warn] [pid 3344:tid 1176] (OS 109)The pipe has been ended.  : [client 127.0.0.1:50153] mod_fcgid: get overlap result error, referer: http://localhost/Sandbox/Forms/
[Wed Apr 11 16:24:55.959158 2012] [:warn] [pid 3344:tid 1176] (OS 109)The pipe has been ended.  : [client 127.0.0.1:50153] mod_fcgid: ap_pass_brigade failed in handle_request_ipc function, referer: http://localhost/Sandbox/Forms/

 

I have no PHP errors in the PHP error log. (Yes, it's enabled)

 

My Local Setup

 

I'm running a Beta version on WAMP on my home PC, which is a 64-bit Windows HP system. I've been working on a project, using the Beta build of WAMP for a month now (I'm playing with Traits in PHP 5.4, which is why I'm using the Beta build) and I've had no issues until now. This is a fresh install of WAMP and I have made no changes to anything since I installed it. My installation of WAMP is on an empty secondary drive (B:) and always has been.

 

As the issue appears to be mod_fcgid related, I've taken the liberty to find the configuration for it, which is as follows.

 

<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi .php
FcgidInitialEnv PHPRC        "B:/wamp/bin/apache/apache2.3.14/bin"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS      1000
FcgidMaxRequestsPerProcess                 1000
FcgidMaxProcesses                          15
MaxRequestLen                              25728640
FcgidIOTimeout                             120
FcgidIdleTimeout                           120
FcgidConnectTimeout                        10 
FcgidWrapper "B:/wamp/bin/php/php5.4/php-cgi.exe" .php
AddType application/x-httpd-php .php
</IfModule>

 

The really bizarre bit :S

 

In order to explain the bizarre bit, I need to explain a little about the project I am working on.....

 

I'm currently working on a Form Generation utility, which will generate a full HTML form, but is also capable of automatically sanitizing and validating it's input. I hate form handling, it's dull, thought this would be cool.

Here is a screenshot of a form generated using the utility so far for sake of understanding: Generated Form

 

The project is fully Object Oriented and works by simply creating new Element objects and adding them to the Form utility, like so.... (Not the full code)

 

<?php
// Checkboxes
    $Checkbox1 = new Element_Checkbox('Sauce');
    $Checkbox1->setAttributes(array('name' => 'sauce', 'id' => 'sauce'));
    $Checkbox1->setSelected(array('ketchup'));
    $Checkbox1->setOptions(
        array(
            'ketchup'     => 'Tomato Ketchup', 
            'salad cream' => 'Salad Cream', 
            'mustard'     => 'English Mustard',
            'brown sauce' => 'Brown Sauce',
            'radish'      => 'Horse Radish',
            'mint'        => 'Mint Sauce'
        )
    );

    // Radios
    $Radio1 = new Element_Radio('Gender');
    $Radio1->setAttributes(array('name' => 'gender', 'id' => 'gender'));
    $Radio1->setSelected('hidden');
    $Radio1->setOptions(
        array(
            'hidden' => 'Disclosed',
            'male'   => 'Male',
            'female' => 'Female'
        )
    );

    // Add elements to the form..
    $Form->addElement($Checkbox1);
    $Form->addElement($Radio1);
    $Form->addElement($Button1);

 

Now, each element inherits (use's) a trait called TElement (Which is where setAttributes() comes from in the above code) and this works fine. The form is generated, I can submit the form, the Form Utility automatically sanitizes and validates the input and I get an array of clean input ready to use.. Win..

 

However, I've gotten to the point where some elements will need custom filtering/validation rules, such as being able to set the minimum or maximum acceptable length of the user input, so I made a new trait called TElementRules.

 

It's the new TElementRules trait that seems to be triggering the 500 Internal, but in a very bizarre manner. First of all, here is the full code for the TElementRules trait.

 

<?php

/**
* TElementRules.php
*
* @package GameFrame  
* @author Daniel J Paddison
* @copyright FeudalRox 
* @version 1.0.0
* @filesource
*/

/**
* TElementRules
* A trait for form elements which need more specific/custom rule sets.
*
* @package GameFrame
* @subpackage Elements
*/

trait TElementRules
{
    /**
     * @var array Will hold all custom rules to be applied to the element.
     */
     
    private $_rules = array();
    
    /**
     * @var string A value that user input must match.
     */
     
    private $_inputMatch = null;
    
    /**
     * @var integer The minimum length of the input.
     */
     
    private $_minLength = 0;
    
    /**
     * @var integer|null The maxmimum length of the input. Defaults to null if not required.
     */
     
    private $_maxLength = null;
    
    /**
     * TElementRules::getRuleset()
     * Returns an array of custom rules (Validators/Filters) for the element.
     * 
     * @return array
     */
     
    public function getRuleset(){
        return $this->_rules;
    }
    
    /**
     * TElementRules::setInputMatch()
     * Sets a value, that any input for this element, must match.
     * 
     * @param mixed $value The value that user input must match.
     */
     
    public function setInputMatch($value = null)
    {
        $this->_inputMatch = $value;
        $this->_rules[]    = 'input_match';
    }
    
    /**
     * TElementRules::getInputMatch()
     * Returns the set value that input must match.
     * 
     * @return mixed
     */
     
    public function getInputMatch(){
        return $this->_inputMatch;
    }
    
    /**
     * TElementRules::validateInputMatch()
     * Validates the input value to the value specified for the Input Match.
     * Note: This method is called internally from Form_Input::validateRuleset()
     * 
     * @param string $value The input to match against $this->_inputMatch
     * @return boolean
     */
     
    public function validateInputMatch($value){
        return ($value === $this->getInputMatch()) ? true : false;
    }
    
    /**
     * TElementRules::setMinimumLength()
     * Sets the minimum acceptable length of the value.
     * 
     * @param integer $length The minimum length.
     */
     
    public function setMinimumLength($length = 0)
    {
        $this->_minLength = (int)$length;
        $this->_rules[]   = 'min_length';
    }
    
    /**
     * TElementRules::getMinimumLength()
     * Returns the minimum acceptable length of the input.
     * 
     * @return integer
     */
     
    public function getMinimumLength(){
        return $this->_minLength;
    }
    
    /**
     * TElementRules::validateMinimumLength()
     * Makes sure the value is equal to, or longer than the minumum allowed length.
     * Note: This method is called internally from Form_Input::validateRuleset()
     * 
     * @param string $value The value to validate.
     * @return boolean
     */
     
    public function validateMinimumLength($value){
        return (strlen($value) < $this->getMinimumLength()) ? false : true;
    }
    
    /**
     * TElementRules::setMaximumLength()
     * Sets the maxmimum acceptable length of the input.
     * 
     * @param integer|null $length The maxmimum acceptable length of the input.
     */
     
    public function setMaximumLength($length = null)
    {
        if(!is_null($length)){
            $this->_maxLength = (int)$length;
            $this->_rules[]   = 'max_length';   
        }      
    }
    
    /**
     * TElementRules::getMaximumLength()
     * Returns the maximum acceptable length of the input.
     * 
     * @return integer
     */
     
    public function getMaximumLength(){
        return $this->_maxLength;
    }
    
    /**
     * TElementRules::validateMaximumLength()
     * Makes sure the value is equal to, or shorter than the maximum allowed length.
     * Note: This method is called internally from Form_Input::validateRuleset()
     * 
     * @param string $value The value to validate.
     * @return boolean
     */
     
    public function validateMaximumLength($value){
        return strlen($value) > $this->getMaximumLength() ? false : true;
    }
    
    /**
     * TElementRules::setLengthRange()
     * Sets the minimum and maximum acceptable length of the input.
     * 
     * @param integer $min The minimum acceptable length of the input.
     * @param integer $max The maximum acceptable length of the input.
     */
     
    public function setLengthRange($min = 0, $max = 255)
    {
        $this->_minLength = (int)$min;
        $this->_maxLength = (int)$max;
        $this->_rules[]   = 'length_range';
    }
    
    /**
     * TElementRules::getLengthRange()
     * Returns the minimum and maximum acceptable length of the input.
     * 
     * @return array
     */
     
    public function getLengthRange()
    {
        $range = array();
        $range['min'] = $this->getMinimumLength();
        $range['max'] = $this->getMaximumLength();
        
        return $range;
    }
    
    /**
     * TElementRules::validateLengthRange()
     * Makes sure the value is between a given length range.
     * Note: This method is called internally from Form_Input::validateRuleset()
     * 
     * @param string $value The value to validate.
     * @return boolean
     */
     
    public function validateLengthRange($value)
    {
        $length = strlen($value);
        
        if($length < $this->getMinimumLength() && $length > $this->getMaximumLength())
            return false;
        
        return true;
    }
}

 

I'd like to draw your attention to the last three methods, setLengthRange(), getLengthRange() and validateLengthRange().. Weirdly, these appear to be the culprit (But only when submitting the form (I've already tried increasing POST size to 12m))... If I comment out, or delete those three methods and then submit the form, everything works fine again. At first I thought I made an error in the methods.... Nope.. Even if I replace those methods with public function one(), two() and three() and leave their code bodies empty, the 500 Internal comes back  :confused: :confused: :confused: BIZARRE! It's almost like the trait refuses to take on any more methods....  :wtf:

 

 

 

I have no idea what's going on, nor have I ever, in the 8 years of PHP, encountered this...

If you managed to read my post all the way through, thanks! I know it was a little long winded, but I couldn't really explain the issue without explaining the project that's causing it.

 

Thanks in advance!

Dan.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.