diff --git a/app/Console/Command/RebuildForumCacheCommand.php b/app/Console/Command/RebuildForumCacheCommand.php index e07e501..999adbe 100644 --- a/app/Console/Command/RebuildForumCacheCommand.php +++ b/app/Console/Command/RebuildForumCacheCommand.php @@ -35,7 +35,7 @@ class RebuildForumCacheCommand extends Command $posts = DB::table('posts')->get(['post_id']); foreach ($posts as $post) { - (new Post($post->post_id))->update(true); + (new Post($post->post_id))->update(); } $this->getLogger()->writeln("Done!"); diff --git a/app/Forum/Post.php b/app/Forum/Post.php index 5516a35..067b68a 100644 --- a/app/Forum/Post.php +++ b/app/Forum/Post.php @@ -8,7 +8,7 @@ namespace Sakura\Forum; use Sakura\BBCode\Parser as BBParser; use Sakura\DB; -use Sakura\Exception; +use Sakura\Exceptions\NetAddressTypeException; use Sakura\Net; use Sakura\User; @@ -126,7 +126,7 @@ class Post // Temporary backwards compatible IP storage system try { $this->ip = Net::ntop($postRow->poster_ip); - } catch (Exception $e) { + } catch (NetAddressTypeException $e) { $this->ip = $postRow->poster_ip; $this->update(); } @@ -183,10 +183,9 @@ class Post /** * Commit the changes to the Database. - * @param bool $ignoreIp * @return Post */ - public function update(bool $ignoreIp = false): Post + public function update(): Post { // Create a topic object $topic = new Topic($this->topic); @@ -198,7 +197,7 @@ class Post 'topic_id' => $topic->id, 'forum_id' => $topic->forum, '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_subject' => $this->subject, 'post_text' => $this->text,