Vendorize ZF1, fix PHPUnit and configure travis

This a a rather large commit due to the nature of the stuff it is touching. To get PHPUnit up and running again I had to update some deps and I did so by vendorizing them. The vendorizing of zf1 makes sense since distros are already considering to drop it from their repos.

* [x] install vendorized zf1 with composer
* [x] load composer autoloader before zf1
* [x] Implement headAction for all Zend_Rest_Controller based controllers
* [x] switch to yml dataset to get around string only limitations of xml sets (also removed warning in readme)
* [x] use year 2044 as hardcoded date for tests since it is in the future and has the same days like previously used 2016
* [x] make tests easier to run when accessing phpunit directly
* [x] clean up test helper to always use airtime.conf
* [x] switch test dbname to libretime_test
* [x] test db username password switched to libretime/libretime
* [x] install phpunit with composer in a clear version (make tests easier to reproduce on other platforms)
* [x] remove local libs from airtime repo (most of airtime_mvc/library was not needed of in vendor already)
* [x] configure composer autoloading and use it (also removed requires that are not needed anymore)
* [x] add LibreTime prefix for FileNotFoundException (phing had a similar class and these are all pre-namespace style)
* [x] add .travis.yml file
* [x] make etc and logdir configurable with LIBRETIME_CONF_DIR and LIBRETIME_LOG_DIR env (so travis can change it)
* [x] slight cleanup in config for travis not to fail
* [x] add cloud_storage.conf for during test runs
* [x] rewrite mvc testing docs and move them to docs/ folder
* [x] don't use `static::class` in a class that does not have a parent class, use `__CLASS__` instead.
* [x] don't use `<ClassName>::class`, since we already know what class we want `"<ClassName>"` ist just fine.
* [x] fix "can't use method in write context" errors on 5.4 (also helps the optimizer)
* [x] add build status badge on main README.md

Fixes https://github.com/LibreTime/libretime/issues/4

The PHP parts of https://github.com/LibreTime/libretime/pull/10 get obsoleted by this change and it will need rebasing.

This also contains https://github.com/LibreTime/libretime/pull/8, the late static binding compat code was broken for no reason and until CentOS drops php 5.4 there is no reason I'm aware of not to support it. I inlined #8 since the test would be failing on php 5.4 without the change.

If you want to run tests you need to run `composer install` in the root directory and then `cd airtime_mvc/tests && ../../vendor/bin/phpunit`. For the tests to run the user `libretime` needs to be allowed to create the `libretime_test` database. See `docs/TESTING.md` for more info on getting set up.
This commit is contained in:
Lucas Bickel 2017-02-20 21:47:53 +01:00
parent 95ce7ef880
commit 625f92fe44
456 changed files with 3493 additions and 64496 deletions

View file

@ -10,57 +10,9 @@ if (!isset($configRun) || !$configRun) {
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}
//Composer's autoloader
require_once 'autoload.php';
require_once CONFIG_PATH . "constants.php";
/* Common */
require_once "DateHelper.php";
require_once "LocaleHelper.php";
require_once "FileDataHelper.php";
require_once "HTTPHelper.php";
require_once "FileIO.php";
require_once "OsPath.php";
require_once "Database.php";
require_once "ProvisioningHelper.php";
require_once "SecurityHelper.php";
require_once "SessionHelper.php";
require_once "GoogleAnalytics.php";
require_once "Timezone.php";
require_once "CeleryManager.php";
require_once "TaskManager.php";
require_once "PodcastManager.php";
require_once "UsabilityHints.php";
require_once __DIR__.'/models/formatters/LengthFormatter.php';
require_once __DIR__.'/common/widgets/Table.php';
/* Models */
require_once "Auth.php";
require_once 'Preference.php';
require_once 'Locale.php';
/* Enums */
require_once "Enum.php";
require_once "MediaType.php";
require_once "HttpRequestType.php";
/* Interfaces */
require_once "OAuth2.php";
require_once "OAuth2Controller.php";
require_once "Publish.php";
/* Factories */
require_once __DIR__.'/services/CeleryServiceFactory.php';
require_once __DIR__.'/services/PublishServiceFactory.php';
require_once __DIR__.'/forms/helpers/ValidationTypes.php';
require_once __DIR__.'/forms/helpers/CustomDecorators.php';
require_once __DIR__.'/controllers/plugins/PageLayoutInitPlugin.php';
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
require_once __DIR__.'/controllers/plugins/Maintenance.php';
require_once __DIR__.'/controllers/plugins/ConversionTracking.php';
require_once __DIR__.'/modules/rest/controllers/ShowImageController.php';
require_once __DIR__.'/modules/rest/controllers/MediaController.php';
require_once __DIR__.'/upgrade/Upgrades.php';
require_once (APPLICATION_PATH . "/logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
Logging::setLogPath(LIBRETIME_LOG_DIR . '/zendphp.log');
// We need to manually route because we can't load Zend without the database being initialized first.
if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) {

View file

@ -48,11 +48,6 @@ set_include_path(APPLICATION_PATH . 'controllers' . PATH_SEPARATOR . get_include
//Controller plugins.
set_include_path(APPLICATION_PATH . 'controllers/plugins' . PATH_SEPARATOR . get_include_path());
//Zend framework
if (file_exists('/usr/share/php/libzend-framework-php')) {
set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
}
//Services.
set_include_path(APPLICATION_PATH . '/services/' . PATH_SEPARATOR . get_include_path());
@ -65,7 +60,8 @@ set_include_path(APPLICATION_PATH . '/upgrade/' . PATH_SEPARATOR . get_include_p
//Common directory
set_include_path(APPLICATION_PATH . '/common/' . PATH_SEPARATOR . get_include_path());
//Composer's autoloader
require_once 'autoload.php';
/** Zend_Application */
require_once 'Zend/Application.php';
@ -75,7 +71,7 @@ $application = new Zend_Application(
);
require_once(APPLICATION_PATH . "logging/Logging.php");
Logging::setLogPath('/var/log/airtime/zendphp.log');
Logging::setLogPath(LIBRETIME_LOG_DIR . '/zendphp.log');
Logging::setupParseErrorLogging();
// Create application, bootstrap, and run

View file

@ -1,8 +1,5 @@
<?php
require_once 'StorageBackend.php';
require_once 'Billing.php';
use Aws\S3\S3Client;
class Amazon_S3StorageBackend extends StorageBackend

View file

@ -1,8 +1,5 @@
<?php
require_once 'StorageBackend.php';
require_once 'FileStorageBackend.php';
require_once 'Amazon_S3StorageBackend.php';
/**
*

View file

@ -22,7 +22,7 @@ class Application_Common_FileIO
{
$fm = @fopen($filePath, 'rb');
if (!$fm) {
throw new FileNotFoundException($filePath);
throw new LibreTimeFileNotFoundException($filePath);
}
//Note that $size is allowed to be zero. If that's the case, it means we don't

View file

@ -56,7 +56,7 @@ class PodcastManager {
protected static function _findUningestedEpisodes($podcast, $service) {
$episodeList = $service->getPodcastEpisodes($podcast->getDbPodcastId());
$episodes = array();
usort($episodeList, array(static::class, "_sortByEpisodePubDate"));
usort($episodeList, array(__CLASS__, "_sortByEpisodePubDate"));
for ($i = 0; $i < sizeof($episodeList); $i++) {
$episodeData = $episodeList[$i];
$ts = $podcast->getDbAutoIngestTimestamp();

View file

@ -351,8 +351,7 @@ class TaskFactory {
*/
private static function _isTask($c) {
$reflect = new ReflectionClass($c);
$clazz = version_compare(phpversion(), '5.5.0', '<') ? "AirtimeTask" : AirtimeTask::class;
return $reflect->implementsInterface($clazz);
return $reflect->implementsInterface('AirtimeTask');
}
/**

View file

@ -1,6 +1,5 @@
<?php
require_once 'Acl_plugin.php';
$ccAcl = new Zend_Acl();

View file

@ -1,9 +1,11 @@
<?php
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
* /etc/airtime/airtime.conf
* LIBRETIME_CONF_DIR/airtime.conf
*/
require_once __DIR__ . '/constants.php';
class Config {
private static $CC_CONFIG = null;
private static $rootDir;
@ -12,10 +14,6 @@ class Config {
self::$rootDir = __DIR__."/../..";
$CC_CONFIG = array(
/* ================================================ storage configuration */
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
"rootDir" => self::$rootDir
);
@ -23,7 +21,7 @@ class Config {
if (getenv('AIRTIME_UNIT_TEST') == '1') {
$filename = "airtime.conf";
} else {
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . "/airtime.conf";
}
$values = parse_ini_file($filename, true);
@ -51,11 +49,11 @@ class Config {
}
// Parse separate conf file for cloud storage values
$cloudStorageConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/cloud_storage.conf";
$cloudStorageConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/cloud_storage.conf";
if (!file_exists($cloudStorageConfig)) {
// If the dev env specific cloud_storage.conf doesn't exist default
// to the production cloud_storage.conf
$cloudStorageConfig = "/etc/airtime-saas/production/cloud_storage.conf";
$cloudStorageConfig = LIBRETIME_CONF_DIR . "/production/cloud_storage.conf";
}
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
@ -86,11 +84,11 @@ class Config {
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
$globalAirtimeConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/airtime.conf";
$globalAirtimeConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/airtime.conf";
if (!file_exists($globalAirtimeConfig)) {
// If the dev env specific airtime.conf doesn't exist default
// to the production airtime.conf
$globalAirtimeConfig = "/etc/airtime-saas/production/airtime.conf";
$globalAirtimeConfig = LIBRETIME_CONF_DIR . "/production/airtime.conf";
}
$globalAirtimeConfigValues = parse_ini_file($globalAirtimeConfig, true);
$CC_CONFIG['soundcloud-client-id'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_id'];

View file

@ -36,6 +36,10 @@ define('AIRTIME_API_VERSION' , '1.1');
// XXX: it's important that we upgrade this every time we add an upgrade!
define('AIRTIME_CODE_VERSION' , '2.5.16');
// grab values from env (i'll do this everywhere with a small function if we like it)
define('LIBRETIME_CONF_DIR', getenv('LIBRETIME_CONF_DIR') ? getenv('LIBRETIME_CONF_DIR') : '/etc/airtime');
define('LIBRETIME_LOG_DIR', getenv('LIBRETIME_LOG_DIR') ? getenv('LIBRETIME_LOG_DIR') : '/var/log/airtime');
// Defaults
define('DEFAULT_LOGO_PLACEHOLDER', 1);
define('DEFAULT_LOGO_FILE', 'images/airtime_logo.png');

View file

@ -1,6 +1,4 @@
<?php
require_once('WidgetHelper.php');
require_once('TuneIn.php');
class ApiController extends Zend_Controller_Action
{
@ -11,8 +9,10 @@ class ApiController extends Zend_Controller_Action
public function init()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->view) { // skip if already missing (ie in tests)
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
//Ignore API key and session authentication for these APIs:
$ignoreAuth = array("live-info",
@ -135,8 +135,7 @@ class ApiController extends Zend_Controller_Action
*/
public function pollCeleryAction() {
$taskManager = TaskManager::getInstance();
$clazz = version_compare(phpversion(), '5.5.0', '<') ? get_class(new CeleryTask) : CeleryTask::class;
$taskManager->runTask($clazz);
$taskManager->runTask('CeleryTask');
}
/**
@ -498,7 +497,7 @@ class ApiController extends Zend_Controller_Action
// Sometimes end users may be looking at stale data - if an image is removed
// but has been cached in a client's browser this will throw an exception
Application_Common_FileIO::smartReadFile($path, filesize($path), $mime_type);
} catch(FileNotFoundException $e) {
} catch(LibreTimeFileNotFoundException $e) {
//throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path");
$this->_redirect('api/station-logo');
return;

View file

@ -1,6 +1,5 @@
<?php
require_once('Billing.php');
define('VAT_RATE', 19.00);
class BillingController extends Zend_Controller_Action {

View file

@ -1,7 +1,5 @@
<?php
require_once(__DIR__.'/../common/widgets/Table.php');
class DashboardController extends Zend_Controller_Action
{

View file

@ -1,5 +1,4 @@
<?php
require_once('WidgetHelper.php');
class EmbedController extends Zend_Controller_Action
{

View file

@ -1,9 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
require_once 'formatters/SamplerateFormatter.php';
require_once 'formatters/BitrateFormatter.php';
class LibraryController extends Zend_Controller_Action
{

View file

@ -1,8 +1,5 @@
<?php
require_once('WhmcsLoginController.php');
require_once('CORSHelper.php');
class LoginController extends Zend_Controller_Action
{
@ -168,13 +165,16 @@ class LoginController extends Zend_Controller_Action
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$query = CcSubjsQuery::create();
if (empty($form->username->getValue())) {
$query->filterByDbEmail($form->email->getValue());
} else if (empty($form->email->getValue())) {
$query->filterByDbLogin($form->username->getValue());
$username = $form->userName->getValue();
$email = $form->email->getValue();
if (empty($username)) {
$query->filterByDbEmail($email);
} else if (empty($email)) {
$query->filterByDbLogin($username);
} else {
$query->filterByDbEmail($form->email->getValue())
->filterByDbLogin($form->username->getValue());
$query->filterByDbEmail($email)
->filterByDbLogin($username);
}
$user = $query->findOne();

View file

@ -1,7 +1,5 @@
<?php
require_once 'ProxyStorageBackend.php';
use Aws\S3\S3Client;
class ProvisioningController extends Zend_Controller_Action

View file

@ -1,8 +1,4 @@
<?php
require_once('TuneIn.php');
$filepath = realpath (dirname(__FILE__));
require_once($filepath."/../modules/rest/controllers/MediaController.php");
class ScheduleController extends Zend_Controller_Action
{

View file

@ -1,7 +1,5 @@
<?php
require_once('CORSHelper.php');
class ShowbuilderController extends Zend_Controller_Action
{

View file

@ -1,8 +1,5 @@
<?php
require_once "ThirdPartyController.php";
require_once "ise/php-soundcloud/src/Soundcloud/Service.php";
class SoundcloudController extends ThirdPartyController implements OAuth2Controller {
/**

View file

@ -1,7 +1,5 @@
<?php
require_once("Upgrades.php");
class UpgradeController extends Zend_Controller_Action
{
public function indexAction()

View file

@ -64,8 +64,7 @@ class PageLayoutInitPlugin extends Zend_Controller_Plugin_Abstract
// We can't afford to wait 7 minutes to run an upgrade: users could
// have several minutes of database errors while waiting for a
// schema change upgrade to happen after a deployment
$clazz = version_compare(phpversion(), '5.5.0', '<') ? get_class(new UpgradeTask) : UpgradeTask::class;
$taskManager->runTask($clazz);
$taskManager->runTask('UpgradeTask');
// Piggyback the TaskManager onto API calls. This provides guaranteed consistency
// (there is at least one API call made from pypo to Airtime every 7 minutes) and

View file

@ -1,5 +1,4 @@
<?php
require_once 'customvalidators/ConditionalNotEmpty.php';
class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
{

View file

@ -1,7 +1,5 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_AddShowStyle extends Zend_Form_SubForm
{

View file

@ -1,5 +1,4 @@
<?php
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
class Application_Form_AddUser extends Zend_Form
{

View file

@ -1,5 +1,4 @@
<?php
require_once 'Zend/Locale.php';
class Application_Form_BillingClient extends Zend_Form
{

View file

@ -1,5 +1,4 @@
<?php
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
class Application_Form_EditUser extends Zend_Form
{

View file

@ -1,6 +1,4 @@
<?php
require_once 'customfilters/ImageSize.php';
<?php
class Application_Form_GeneralPreferences extends Zend_Form_SubForm
{

View file

@ -1,7 +1,5 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_RegisterAirtime extends Zend_Form
{

View file

@ -1,5 +1,4 @@
<?php
require_once 'customvalidators/ConditionalNotEmpty.php';
class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
{

View file

@ -1,5 +1,4 @@
<?php
require_once 'customvalidators/ConditionalNotEmpty.php';
class Application_Form_TuneInPreferences extends Zend_Form_SubForm
{

View file

@ -42,7 +42,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
var schedulePreLoaded = <?php
//Awful hack to speed up loading - Embed the schedule in the response so that the dashboard
//doesn't have to make a separate AJAX request to get this data.
require_once("ScheduleController.php");
ScheduleController::printCurrentPlaylistForEmbedding();
?>;
//The DOM elements that these calls depend on exist by this point:

View file

@ -1,5 +1,4 @@
<?php
require_once('SentryLogging.php');
class Logging {

View file

@ -1,7 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
/**
*
* @package Airtime

View file

@ -1,7 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
/**
*
* @package Airtime

View file

@ -1,8 +1,5 @@
<?php
require_once 'StreamSetting.php';
require_once 'Cache.php';
class Application_Model_Preference
{

View file

@ -1,6 +1,4 @@
<?php
require_once 'php-amqplib/amqp.inc';
require_once 'massivescale/celery-php/celery.php';
class Application_Model_RabbitMq
{

View file

@ -1,8 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
require_once 'formatters/TimeFilledFormatter.php';
class Application_Model_ShowBuilder
{
private $timezone;

View file

@ -1,7 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
class Application_Model_ShowInstance
{
private $_instanceId;

View file

@ -1,9 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
require_once 'formatters/SamplerateFormatter.php';
require_once 'formatters/BitrateFormatter.php';
/**
* Application_Model_StoredFile class
*

View file

@ -16,7 +16,7 @@ class InvalidMetadataException extends Exception
{
}
class FileNotFoundException extends Exception
class LibreTimeFileNotFoundException extends Exception
{
}
@ -67,7 +67,7 @@ class CcFiles extends BaseCcFiles {
if ($file) {
return CcFiles::sanitizeResponse($file);
} else {
throw new FileNotFoundException();
throw new LibreTimeFileNotFoundException();
}
}
@ -174,7 +174,7 @@ class CcFiles extends BaseCcFiles {
* @param $fileArray array An associative array containing metadata. Replaces those fields if they exist.
* @return array A sanitized version of the file metadata array.
* @throws Exception
* @throws FileNotFoundException
* @throws LibreTimeFileNotFoundException
* @throws PropelException
*/
public static function updateFromArray($fileId, $fileArray)
@ -196,7 +196,7 @@ class CcFiles extends BaseCcFiles {
$fileSizeBytes = $fileArray["filesize"];
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
throw new FileNotFoundException("Invalid filesize for $fileId");
throw new LibreTimeFileNotFoundException("Invalid filesize for $fileId");
}
$cloudFile = new CloudFile();
@ -219,7 +219,7 @@ class CcFiles extends BaseCcFiles {
if (isset($fileArray["full_path"])) {
$fileSizeBytes = filesize($fileArray["full_path"]);
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
throw new FileNotFoundException("Invalid filesize for $fileId");
throw new LibreTimeFileNotFoundException("Invalid filesize for $fileId");
}
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
@ -235,14 +235,14 @@ class CcFiles extends BaseCcFiles {
}
}
} else {
throw new FileNotFoundException();
throw new LibreTimeFileNotFoundException();
}
$now = new DateTime("now", new DateTimeZone("UTC"));
$file->setDbMtime($now);
$file->save();
}
catch (FileNotFoundException $e)
catch (LibreTimeFileNotFoundException $e)
{
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED);
$file->setDbHidden(true);
@ -258,7 +258,7 @@ class CcFiles extends BaseCcFiles {
* @throws DeleteScheduledFileException
* @throws Exception
* @throws FileNoPermissionException
* @throws FileNotFoundException
* @throws LibreTimeFileNotFoundException
* @throws PropelException
*/
public static function deleteById($id)
@ -269,7 +269,7 @@ class CcFiles extends BaseCcFiles {
$storedFile = Application_Model_StoredFile::RecallById($id, $con);
$storedFile->delete();
} else {
throw new FileNotFoundException();
throw new LibreTimeFileNotFoundException();
}
}

View file

@ -1,7 +1,5 @@
<?php
require_once 'ProxyStorageBackend.php';
/**
* Skeleton subclass for representing a row from the 'cloud_file' table.
*

View file

@ -3,11 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$WHITE_SCREEN_OF_DEATH = false;
require_once(dirname(__FILE__).'/../../configs/conf.php');
require_once('PHPUnit.php');
require_once 'StoredFileTests.php';
require_once 'SchedulerTests.php';
//require_once 'SchedulerExportTests.php';
require_once 'PlaylistTests.php';
//$suite = new PHPUnit_TestSuite("PlayListTests");
//$suite = new PHPUnit_TestSuite("SchedulerTests");

View file

@ -1,7 +1,5 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerExportTests extends PHPUnit_TestCase {
function setup() {
global $CC_CONFIG;

View file

@ -1,5 +1,4 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerTests extends PHPUnit_TestCase {

View file

@ -1,5 +1,4 @@
<?php
require_once(dirname(__FILE__).'/../StoredFile.php');
class StoredFileTest extends PHPUnit_TestCase {

View file

@ -1,25 +0,0 @@
<?php
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
// Initialize Propel with the runtime configuration
//Example how to use PDO:
//Propel::init(__DIR__."/../propel-db/build/conf/airtime-conf.php");
//Add the generated 'classes' directory to the include path
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
$con = Propel::getConnection("campcaster");
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '2010-01-01 00:00:00.000') "
." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
$rows1 = $con->query($sql);
var_dump($rows1->fetchAll());
$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
$rows2 = $con->query($sql2);
var_dump($rows2->fetchAll());
$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
$result3 = $con->query($sql3);
var_dump($result3->fetchAll());

View file

@ -1,7 +1,5 @@
<?php
require_once 'RouteController.php';
class Rest_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initRouter()

View file

@ -1,7 +1,5 @@
<?php
require_once 'ProxyStorageBackend.php';
class Rest_MediaController extends Zend_Rest_Controller
{
public function init()
@ -11,6 +9,16 @@ class Rest_MediaController extends Zend_Rest_Controller
// Remove reliance on .phtml files to render requests
$this->_helper->viewRenderer->setNoRender(true);
}
/**
* headAction is needed as it is defined as an abstract function in the base controller
*
* @return void
*/
public function headAction()
{
Logging::info("HEAD action received");
}
public function indexAction()
{
@ -76,7 +84,7 @@ class Rest_MediaController extends Zend_Rest_Controller
}
Application_Service_MediaService::streamFileDownload($id, $inline);
}
catch (FileNotFoundException $e) {
catch (LibreTimeFileNotFoundException $e) {
$this->fileNotFoundResponse();
Logging::error($e->getMessage());
}
@ -99,7 +107,7 @@ class Rest_MediaController extends Zend_Rest_Controller
->setHttpResponseCode(200)
->appendBody(json_encode(CcFiles::getSanitizedFileById($id)));
}
catch (FileNotFoundException $e) {
catch (LibreTimeFileNotFoundException $e) {
$this->fileNotFoundResponse();
Logging::error($e->getMessage());
}
@ -160,7 +168,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->invalidDataResponse();
Logging::error($e->getMessage());
}
catch (FileNotFoundException $e) {
catch (LibreTimeFileNotFoundException $e) {
$this->fileNotFoundResponse();
Logging::error($e->getMessage());
}
@ -181,7 +189,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->getResponse()
->setHttpResponseCode(204);
}
catch (FileNotFoundException $e) {
catch (LibreTimeFileNotFoundException $e) {
$this->fileNotFoundResponse();
Logging::error($e->getMessage());
}

View file

@ -1,7 +1,5 @@
<?php
require_once('PodcastFactory.php');
class Rest_PodcastController extends Zend_Rest_Controller
{
@ -14,6 +12,16 @@ class Rest_PodcastController extends Zend_Rest_Controller
$this->view->setScriptPath(APPLICATION_PATH . 'views/scripts/');
}
/**
* headAction is needed as it is defined as an abstract function in the base controller
*
* @return void
*/
public function headAction()
{
Logging::info("HEAD action received");
}
public function indexAction()
{
// Check if offset and limit were sent with request.

View file

@ -17,6 +17,16 @@ class Rest_PodcastEpisodesController extends Zend_Rest_Controller
$this->_service = new Application_Service_PodcastEpisodeService();
}
/**
* headAction is needed as it is defined as an abstract function in the base controller
*
* @return void
*/
public function headAction()
{
Logging::info("HEAD action received");
}
public function indexAction()
{
// podcast ID

View file

@ -12,9 +12,6 @@
* @version 1.2.1
*/
$filepath = realpath(__DIR__);
require_once($filepath . "/../helpers/RestAuth.php");
class Rest_ShowImageController extends Zend_Rest_Controller {
public function init() {
@ -24,6 +21,16 @@ class Rest_ShowImageController extends Zend_Rest_Controller {
$this->_helper->viewRenderer->setNoRender(true);
}
/**
* headAction is needed as it is defined as an abstract function in the base controller
*
* @return void
*/
public function headAction()
{
Logging::info("HEAD action received");
}
public function indexAction() {
Logging::info("INDEX action received");
}

View file

@ -1,7 +1,5 @@
<?php
require_once 'formatters/LengthFormatter.php';
class Application_Service_HistoryService
{
private $con;

View file

@ -1,8 +1,5 @@
<?php
require_once('ProxyStorageBackend.php');
require_once("FileIO.php");
class Application_Service_MediaService
{
@ -56,13 +53,13 @@ class Application_Service_MediaService
* @param $fileId
* @param bool $inline Set the Content-Disposition header to inline to prevent a download dialog from popping up (or attachment if false)
* @throws Exception
* @throws FileNotFoundException
* @throws LibreTimeFileNotFoundException
*/
public static function streamFileDownload($fileId, $inline=false)
{
$media = Application_Model_StoredFile::RecallById($fileId);
if ($media == null) {
throw new FileNotFoundException();
throw new LibreTimeFileNotFoundException();
}
// Make sure we don't have some wrong result because of caching
clearstatcache();
@ -104,7 +101,7 @@ class Application_Service_MediaService
$mimeType = $media->getPropelOrm()->getDbMime();
Application_Common_FileIO::smartReadFile($filePath, $size, $mimeType);
break; //Break out of the loop if we successfully read the file!
} catch (FileNotFoundException $e) {
} catch (LibreTimeFileNotFoundException $e) {
//If we have no alternate filepaths left, then let the exception bubble up.
if (sizeof($filePaths) == 0) {
throw $e;
@ -116,7 +113,7 @@ class Application_Service_MediaService
exit;
} else {
throw new FileNotFoundException($filePath);
throw new LibreTimeFileNotFoundException($filePath);
}
}

View file

@ -354,7 +354,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
*
* @return array array of episode data
*
* @throws CcFiles/FileNotFoundException
* @throws CcFiles/LibreTimeFileNotFoundException
*/
public function _getImportedPodcastEpisodeArray($podcast, $episodes) {
$rss = Application_Service_PodcastService::getPodcastFeed($podcast->getDbUrl());

View file

@ -72,9 +72,13 @@ class Application_Service_PodcastService
//TODO: why is this so slow?
$rss = self::getPodcastFeed($feedUrl);
if (!$rss || !empty($rss->error())) {
if (!$rss) {
throw new InvalidPodcastException();
}
$rssErr = $rss->error();
if (!empty($rssErr)) {
throw new InvalidPodcastException($rssErr);
}
// Ensure we are only creating Podcast with the given URL, and excluding
// any extra data fields that may have been POSTED
@ -87,7 +91,8 @@ class Application_Service_PodcastService
$podcastArray["language"] = htmlspecialchars($rss->get_language());
$podcastArray["copyright"] = htmlspecialchars($rss->get_copyright());
$name = empty($rss->get_author()) ? "" : $rss->get_author()->get_name();
$rssAuthor = $rss->getAuthor();
$name = empty($rssAuthor) ? "" : $rss->rssAuthor->get_name();
$podcastArray["creator"] = htmlspecialchars($name);
$categories = array();

View file

@ -1,7 +1,5 @@
<?php
require_once "ThirdPartyCeleryService.php";
/**
* Service object for dealing with SoundCloud authorization and background tasks
*

View file

@ -1,7 +1,5 @@
<?php
require_once "ThirdPartyService.php";
abstract class Application_Service_ThirdPartyCeleryService extends Application_Service_ThirdPartyService {
/**