0

We've inherited a website that runs on a Mac OSX server (10.5.8). It has the following components:

  • Apache 2.2.25
  • PHP 5.3.27
  • Zend Framework v2.3.0
  • Connects to a PostGres database on another server
    • pdo_pgsql: PostGreSQL 9.2.4

Monday morning we got a call that the website isn't working. The only thing displayed is the website background. When I look in the source for the page I see that I have a start <body> tag and then the document stops.

There is no PHP logging on the site. I made the following changes to the php.ini file:

  • error_reporting = E_ALL (it was ~E_ALL)
  • error_log = /path/to/php_error_log
  • log_errors = On

I then restarted the Apache service. Here's the errors I start to see in the log (it's actually bundled in with the Apache error_log):

PHP Fatal error: Cannot redeclare printMediaIcons() (previously declared in /Library/WebServer/Documents/XXXXX/Website/module/Application/view/layout/header.phtml:20) in /Library/WebServer/Documents/XXXXX/Website/module/Application/view/layout/header.phtml on line 39

I'm not a PHP guy but I understand the error message. What I don't understand is how this could ever work. I want to stress that we didn't change anything on this site.

In an effort to make some headway I edited the header.phtml file and took out the printMediaIcons function and any calls to it. I then get another error, this time from the database:

Tue Nov 03 13:09:05 2015] [error] [client 45.24.29.225] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type boolean: ""' in /Library/WebServer/Documents/XXXXX/Website/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Connection.php:438\nStack trace:\n#0 /Library/WebServer/Documents/XXXXX/Website/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Connection.php(438): PDO->query('SELECT id, time...')\n#1 /Library/WebServer/Documents/XXXXX/Website/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Adapter.php(190): Zend\Db\Adapter\Driver\Pdo\Connection->execute('SELECT id, time...')\n#2 /Library/WebServer/Documents/XXXXX/Website/module/Application/src/Application/Model/BaseModel.php(214): Zend\Db\Adapter\Adapter->query('SELECT id, time...', 'execute')\n#3 /Library/WebServer/Documents/XXXXX/Website/module/Application/src/Application/Model/CalendarModel.php(71): Application\Model\BaseModel->executeQuery('SELECT id, time...')\n#4 /Library/WebSe in /Library/WebServer/Documents/XXXXX/Website/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Connection.php on line 438

The SQL that it's objecting to is a simple statement to read the hours of operation for the business. Here's the function that it's calling:

public function getTodaysHours($timeTypeName) { $timeTypeId = $this->getTimeTypeId($timeTypeName);

            $variableHours = $this->getVariableHours($timeTypeId);

            if($variableHours)
                   return $this->getDisplayForTimes($variableHours['time_from'],

$variableHours['time_to']);

            $sql = sprintf("SELECT id, time_from, time_to, day_of_week
                    FROM open_times
                    WHERE (day_of_week = '%s' OR day_of_week = 'All')
                      AND (is_dst = '%s' OR is_dst IS NULL)
                      AND time_type_id = '%s' ORDER BY day_of_week DESC;",
                      CalendarModel::getToday(), CalendarModel::getIsDst(), $timeTypeId);

            $results = $this->executeQuery($sql);
            $results = $results->toArray();
            $results = current($results);

            return $this->getDisplayForTimes($results['time_from'], $results['time_to']);
    }

The site was working fine last week. I've examined conf files, ini files, error logs and this is all I'm able to turn up. I have no idea what has changed/broken on the server.

Anyone have any ideas on how to start tackling this issue?

0

Found it! The issue is with the getTodaysHours function. Something in that query with regards to the is_dst is causing the error. I returned a dummy value from that function and POOF the site is back up.

I still have no idea how the printMediaFunction was working before. But I've wrapped it in a function_exists check and all is good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.