You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ch...@apache.org on 2009/07/28 11:00:58 UTC

svn commit: r798451 - in /incubator/shindig/trunk/php: src/common/sample/CacheStorageMemcache.php src/social/sample/JsonDbOpensocialService.php test/common/CacheMemcacheTest.php test/index.php test/social/MediaItemRestTest.php test/social/RestBase.php

Author: chabotc
Date: Tue Jul 28 09:00:57 2009
New Revision: 798451

URL: http://svn.apache.org/viewvc?rev=798451&view=rev
Log:
SHINDIG-1128 by lipeng - Fixes a number of strict warnings

Modified:
    incubator/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php
    incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php
    incubator/shindig/trunk/php/test/common/CacheMemcacheTest.php
    incubator/shindig/trunk/php/test/index.php
    incubator/shindig/trunk/php/test/social/MediaItemRestTest.php
    incubator/shindig/trunk/php/test/social/RestBase.php

Modified: incubator/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php (original)
+++ incubator/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php Tue Jul 28 09:00:57 2009
@@ -33,11 +33,11 @@
       $host = Config::get('cache_host');
       $port = Config::get('cache_port');
       if (Config::get('cache_memcache_pconnect')) {
-        if (!self::$memcache->pconnect($host, $port)) {
+        if (!@self::$memcache->pconnect($host, $port)) {
           throw new CacheException("Couldn't connect to memcache server");
         }
       } else {
-        if (!self::$memcache->connect($host, $port)) {
+        if (!@self::$memcache->connect($host, $port)) {
           throw new CacheException("Couldn't connect to memcache server");
         }
       }

Modified: incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php (original)
+++ incubator/shindig/trunk/php/src/social/sample/JsonDbOpensocialService.php Tue Jul 28 09:00:57 2009
@@ -159,7 +159,7 @@
 
   private function getAllAlbums() {
     $db = $this->getDb();
-    $albumTable = $db[self::$ALBUMS_TABLE] ? $db[self::$ALBUMS_TABLE] : array();
+    $albumTable = isset($db[self::$ALBUMS_TABLE]) ? $db[self::$ALBUMS_TABLE] : array();
     $allAlbums = array();
     foreach ($albumTable as $key => $value) {
       $allAlbums[$key] = $value;
@@ -169,7 +169,7 @@
 
   private function getAllMediaItems() {
     $db = $this->getDb();
-    $mediaItemsTable = $db[self::$MEDIA_ITEMS_TABLE] ? $db[self::$MEDIA_ITEMS_TABLE] : array();
+    $mediaItemsTable = isset($db[self::$MEDIA_ITEMS_TABLE]) ? $db[self::$MEDIA_ITEMS_TABLE] : array();
     $allMediaItems = array();
     foreach ($mediaItemsTable as $key => $value) {
       $allMediaItems[$key] = $value;
@@ -251,6 +251,7 @@
         }
         if ($fields[0] != '@all') {
           $newPerson = array();
+          $newPerson['id'] = $id;
           $newPerson['isOwner'] = isset($person['isOwner']) ? $person['isOwner'] : false;
           $newPerson['isViewer'] = isset($person['isViewer']) ? $person['isViewer'] : false;
           $newPerson['name'] = $person['name'];
@@ -263,7 +264,7 @@
           }
           $person = $newPerson;
         }
-        $people[$id] = $person;
+        $people[] = $person;
       }
     }
     if ($sortOrder == 'name') {
@@ -362,7 +363,8 @@
       }
     }
     $allData = $this->getAllData();
-    $person = $allData[$userId->getUserId($token)];
+    $tmpUserId = $userId->getUserId($token);
+    $person = isset($allData[$tmpUserId]) ? $allData[$tmpUserId] : array();
     switch ($groupId->getType()) {
       case 'self':
         foreach ($fields as $key => $present) {
@@ -383,7 +385,7 @@
   public function deletePersonData($userId, GroupId $groupId, $appId, $fields, SecurityToken $token) {
     $db = $this->getDb();
     $allData = $this->getAllData();
-    if ($fields == null || $fields[0] == '*') {
+    if ($fields == null || (isset($fields[0]) && $fields[0] == '*')) {
       $allData[$userId->getUserId($token)] = null;
       $db[self::$DATA_TABLE] = $allData;
       $this->saveDb($db);
@@ -632,7 +634,7 @@
     try {
       if (! isset($messagesTable[$userId->getUserId($token)])) {
         $messagesTable[$userId->getUserId($token)] = array();
-      } else if (isset($messagesTable[$userId->getUserId($token)][$msgCollection['id']])) {
+      } else if (isset($msgCollection['id']) && isset($messagesTable[$userId->getUserId($token)][$msgCollection['id']])) {
         throw new SocialSpiException("Message collection already exists.", ResponseError::$BAD_REQUEST);
       }
       $msgCollection['total'] = 0;
@@ -717,7 +719,7 @@
     foreach ($all[$userId->getUserId($token)] as $id => $album) {
       if (empty($albumIds) || in_array($id, $albumIds)) {
         $results[] = $album;
-        $album['mediaItemCount'] = count($allMediaItems[$id]);
+        $album['mediaItemCount'] = isset($allMediaItems[$id]) ? count($allMediaItems[$id]) : 0;
       }
     }
     if ($options) {
@@ -815,7 +817,7 @@
   public function createMediaItem($userId, $groupId, $mediaItem, $data, $token) {
     $all = $this->getAllMediaItems();
     $albumId = $mediaItem['albumId'];
-    $id = count($all[$albumId]) + 1;
+    $id = isset($all[$albumId]) ? (count($all[$albumId]) + 1) : 0;
     $mediaItem['id'] = $id;
     $mediaItem['lastUpdated'] = time();
     if (isset($mediaItem['type'])) {
@@ -824,7 +826,7 @@
         unset($mediaItem['type']);
       }
     }
-    if (! $all[$albumId]) {
+    if (isset($all[$albumId]) && (! $all[$albumId])) {
       $all[$albumId] = array();
     }
     $all[$albumId][$id] = $mediaItem;

Modified: incubator/shindig/trunk/php/test/common/CacheMemcacheTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/common/CacheMemcacheTest.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/common/CacheMemcacheTest.php (original)
+++ incubator/shindig/trunk/php/test/common/CacheMemcacheTest.php Tue Jul 28 09:00:57 2009
@@ -46,7 +46,12 @@
     }
     parent::setUp();
     $this->time = new MockRequestTime();
-    $this->cache = Cache::createCache('CacheStorageMemcache', 'TestCache', $this->time);
+    try {
+      $this->cache = Cache::createCache('CacheStorageMemcache', 'TestCache', $this->time);
+    } catch (Exception $e) {
+      $message = 'memcache server can not connect';
+      throw new PHPUnit_Framework_SkippedTestSuiteError($message);
+    }
     if (! is_resource($this->cache)) {
       $message = 'memcache server can not connect';
       throw new PHPUnit_Framework_SkippedTestSuiteError($message);

Modified: incubator/shindig/trunk/php/test/index.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/index.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/index.php (original)
+++ incubator/shindig/trunk/php/test/index.php Tue Jul 28 09:00:57 2009
@@ -21,6 +21,7 @@
 @date_default_timezone_set(@date_default_timezone_get());
 set_include_path(realpath("../") . PATH_SEPARATOR . realpath("../external/"));
 error_reporting(E_ALL | E_STRICT);
+set_time_limit(60);
 
 require_once "PHPUnit/Framework/TestSuite.php";
 require_once "PHPUnit/TextUI/TestRunner.php";

Modified: incubator/shindig/trunk/php/test/social/MediaItemRestTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/social/MediaItemRestTest.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/social/MediaItemRestTest.php (original)
+++ incubator/shindig/trunk/php/test/social/MediaItemRestTest.php Tue Jul 28 09:00:57 2009
@@ -150,7 +150,7 @@
       "userId" : "example.org:34KJDCSKJN2HHF0DW20394",
       "mediaItems" : [ {
           "id": ' . $mediaItem['id'] . ',
-          "albumId": ' . $mediaItem['albumId'] . '
+          "albumId": "' . $mediaItem['albumId'] . '"
         }
       ]
     }';

Modified: incubator/shindig/trunk/php/test/social/RestBase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/social/RestBase.php?rev=798451&r1=798450&r2=798451&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/social/RestBase.php (original)
+++ incubator/shindig/trunk/php/test/social/RestBase.php Tue Jul 28 09:00:57 2009
@@ -30,8 +30,12 @@
    */
   private $securityToken = '1:1:1:partuza:test.com:1:0';
   // The server to test against. You may need to add shindig to 127.0.0.1 mapping in /etc/hosts.
-  private $restUrl = 'http://shindig/social/rest';
-  
+  private $restUrl = '';
+
+  public function __construct() {
+    $this->restUrl = 'http://' . $_SERVER["HTTP_HOST"] . Config::get('web_prefix') . '/social/rest';
+  }
+
   protected function curlRest($url, $postData, $contentType, $method = 'POST') {
     $ch = curl_init();
     if (substr($url, 0, 1) != '/') {