CC-1927 Remove PEAR DB
* Removed all traces of PEAR functions. * Fixed AirtimeInstall::GetVersionInstalled() to return the correct answer even when it cant connect to the database. Also fixed return value to be consistent on failure. * Fixed phone_home_stat.php and soundcloud-uploader.php
This commit is contained in:
parent
c0da27b445
commit
96b010e7f0
|
@ -123,7 +123,7 @@ class ApiController extends Zend_Controller_Action
|
|||
if (ctype_alnum($file_id) && strlen($file_id) == 32)
|
||||
{
|
||||
$media = Application_Model_StoredFile::RecallByGunid($file_id);
|
||||
if ( $media != null && !PEAR::isError($media))
|
||||
if ( $media != null )
|
||||
{
|
||||
$filepath = $media->getFilePath();
|
||||
if(is_file($filepath)){
|
||||
|
@ -342,8 +342,6 @@ class ApiController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
$data = Application_Model_Schedule::GetScheduledPlaylists();
|
||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
@ -368,12 +366,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$schedule_group_id = $this->_getParam("schedule_id");
|
||||
$media_id = $this->_getParam("media_id");
|
||||
$result = Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
||||
|
||||
if (!PEAR::isError($result)) {
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
} else {
|
||||
echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage()));
|
||||
}
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
}
|
||||
|
||||
public function recordedShowsAction()
|
||||
|
|
|
@ -822,9 +822,6 @@ Logging::log("getting media! - 2");
|
|||
|
||||
$result = null;
|
||||
if ($duplicate) {
|
||||
if (PEAR::isError($duplicate)) {
|
||||
$result = array("code" => 105, "message" => $duplicate->getMessage());
|
||||
}
|
||||
if (file_exists($duplicate->getFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE');
|
||||
$result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server.");
|
||||
|
|
|
@ -3,7 +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('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
require_once 'StoredFileTests.php';
|
||||
require_once 'SchedulerTests.php';
|
||||
|
|
|
@ -46,9 +46,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
function testAddAndRemoveAudioFile() {
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
|
||||
$i = new Application_Model_ScheduleGroup($this->groupIdCreated);
|
||||
$result = $i->remove();
|
||||
|
@ -67,9 +64,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
$group = new Application_Model_ScheduleGroup($this->groupIdCreated);
|
||||
if ($group->count() != 3) {
|
||||
$this->fail("Wrong number of items added.");
|
||||
|
@ -90,10 +84,6 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
function testIsScheduleEmptyInRange() {
|
||||
$i = new Application_Model_ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail($this->groupIdCreated->getMessage());
|
||||
return;
|
||||
}
|
||||
if (Application_Model_Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting empty schedule when it isnt.");
|
||||
return;
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
function __construct($name) {
|
||||
|
@ -21,10 +13,6 @@ class StoredFileTest extends PHPUnit_TestCase {
|
|||
function testGetAudioMetadata() {
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
$metadata = Metadata::LoadFromFile($filePath);
|
||||
if (PEAR::isError($metadata)) {
|
||||
$this->fail($metadata->getMessage());
|
||||
return;
|
||||
}
|
||||
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|
||||
|| ($metadata["audio"]["dataformat"] != "mp3")
|
||||
|| ($metadata["dc:type"] != "Speech")) {
|
||||
|
@ -52,10 +40,6 @@ class StoredFileTest extends PHPUnit_TestCase {
|
|||
$values = array("filepath" => $filePath,
|
||||
"dc:description" => "Unit test ".time());
|
||||
$storedFile = Application_Model_StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
|
|
|
@ -38,10 +38,20 @@ class AirtimeInstall
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of Airtime currently installed.
|
||||
* If not installed, return null.
|
||||
*
|
||||
* @return NULL|string
|
||||
*/
|
||||
public static function GetVersionInstalled()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
} catch (PropelException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (file_exists('/etc/airtime/airtime.conf')) {
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
@ -66,7 +76,7 @@ class AirtimeInstall
|
|||
//echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$version = false;
|
||||
$version = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $version = AirtimeInstall::GetVersionInstalled();
|
|||
// The current version is already installed.
|
||||
echo "* Checking for existing Airtime installation...".PHP_EOL;
|
||||
if (isset($version)){
|
||||
if ($version === false){
|
||||
if (is_null($version)){
|
||||
//version of Airtime older than 1.7.0 detected
|
||||
exit(3);
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,6 @@ set_include_path(APPLICATION_PATH . get_include_path() . PATH_SEPARATOR . '/cont
|
|||
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once(APPLICATION_PATH.'/../library/propel/runtime/lib/Propel.php');
|
||||
|
||||
require_once 'Soundcloud.php';
|
||||
|
@ -31,17 +30,6 @@ require_once 'Preference.php';
|
|||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../../../application/configs/airtime-conf.php");
|
||||
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
|
||||
$playlistName = "pypo_playlist_test";
|
||||
$secondsFromNow = 30;
|
||||
|
||||
|
@ -70,10 +58,6 @@ if (is_null($mediaFile)) {
|
|||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../../audio_samples/vorbis.com/Hydrate-Kenny_Beltrey.ogg");
|
||||
$mediaFile = Application_Model_StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
|
|
@ -29,6 +29,12 @@ require_once($CC_CONFIG['phpDir'].'/application/configs/conf.php');
|
|||
|
||||
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
get_include_path(),
|
||||
realpath($CC_CONFIG['phpDir'] . '/library')
|
||||
)));
|
||||
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/User.php');
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php');
|
||||
|
@ -38,19 +44,8 @@ require_once($CC_CONFIG['phpDir'].'/application/models/ShowInstance.php');
|
|||
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/StreamSetting.php');
|
||||
|
||||
require_once('DB.php');
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
/*echo $CC_DBC->getMessage().PHP_EOL;
|
||||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;*/
|
||||
exit(1);
|
||||
} else {
|
||||
//echo "* Connected to database".PHP_EOL;
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php");
|
||||
|
||||
if(Application_Model_Preference::GetSupportFeedback() == '1'){
|
||||
$infoArray = Application_Model_Preference::GetSystemInfo(true);
|
||||
|
|
|
@ -24,6 +24,12 @@ require_once($CC_CONFIG['phpDir'].'/application/configs/conf.php');
|
|||
|
||||
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
get_include_path(),
|
||||
realpath($CC_CONFIG['phpDir'] . '/library')
|
||||
)));
|
||||
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
|
||||
require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php');
|
||||
|
@ -35,21 +41,8 @@ set_include_path($CC_CONFIG['phpDir']."/application/models" . PATH_SEPARATOR . g
|
|||
require_once($CC_CONFIG['phpDir']."/library/propel/runtime/lib/Propel.php");
|
||||
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf.php");
|
||||
|
||||
require_once('DB.php');
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
/*echo $CC_DBC->getMessage().PHP_EOL;
|
||||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;*/
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
//echo "* Connected to database".PHP_EOL;
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php");
|
||||
|
||||
if(count($argv) != 2){
|
||||
exit;
|
||||
|
|
Loading…
Reference in New Issue