fix wrong exception being catched

This commit is contained in:
flash 2016-12-04 21:00:58 +01:00
parent 2847589199
commit 91c6bb6aa9
2 changed files with 5 additions and 6 deletions

View file

@ -35,7 +35,7 @@ class RebuildForumCacheCommand extends Command
$posts = DB::table('posts')->get(['post_id']); $posts = DB::table('posts')->get(['post_id']);
foreach ($posts as $post) { foreach ($posts as $post) {
(new Post($post->post_id))->update(true); (new Post($post->post_id))->update();
} }
$this->getLogger()->writeln("Done!"); $this->getLogger()->writeln("Done!");

View file

@ -8,7 +8,7 @@ namespace Sakura\Forum;
use Sakura\BBCode\Parser as BBParser; use Sakura\BBCode\Parser as BBParser;
use Sakura\DB; use Sakura\DB;
use Sakura\Exception; use Sakura\Exceptions\NetAddressTypeException;
use Sakura\Net; use Sakura\Net;
use Sakura\User; use Sakura\User;
@ -126,7 +126,7 @@ class Post
// Temporary backwards compatible IP storage system // Temporary backwards compatible IP storage system
try { try {
$this->ip = Net::ntop($postRow->poster_ip); $this->ip = Net::ntop($postRow->poster_ip);
} catch (Exception $e) { } catch (NetAddressTypeException $e) {
$this->ip = $postRow->poster_ip; $this->ip = $postRow->poster_ip;
$this->update(); $this->update();
} }
@ -183,10 +183,9 @@ class Post
/** /**
* Commit the changes to the Database. * Commit the changes to the Database.
* @param bool $ignoreIp
* @return Post * @return Post
*/ */
public function update(bool $ignoreIp = false): Post public function update(): Post
{ {
// Create a topic object // Create a topic object
$topic = new Topic($this->topic); $topic = new Topic($this->topic);
@ -198,7 +197,7 @@ class Post
'topic_id' => $topic->id, 'topic_id' => $topic->id,
'forum_id' => $topic->forum, 'forum_id' => $topic->forum,
'poster_id' => $this->poster->id, 'poster_id' => $this->poster->id,
'poster_ip' => Net::pton($ignoreIp ? $this->ip : Net::ip()), 'poster_ip' => Net::pton($this->ip),
'post_time' => $this->time, 'post_time' => $this->time,
'post_subject' => $this->subject, 'post_subject' => $this->subject,
'post_text' => $this->text, 'post_text' => $this->text,