]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Some Notice::saveNew cleanups.
authorOri Avtalion <ori@avtalion.name>
Tue, 2 Sep 2008 17:38:04 +0000 (13:38 -0400)
committerOri Avtalion <ori@avtalion.name>
Tue, 2 Sep 2008 17:38:04 +0000 (13:38 -0400)
* No need to check $source's value before inserting
* No need to update the notice if the $uri was known in advance

darcs-hash:20080902173804-57fc3-496ceaf8192694db43e62f7af1f57785a1a16a01.gz

classes/Notice.php

index 06750b43638c156e9966b3e34a1fb49ddcbf98d8..6cfd0d7865e889f4ec0538a90f8293c3dd6ce143 100644 (file)
@@ -88,9 +88,8 @@ class Notice extends DB_DataObject
                $notice->created = common_sql_now();
                $notice->content = $content;
                $notice->rendered = common_render_content($notice->content, $notice);
-               if ($source) {
-                       $notice->source = $source;
-               }
+               $notice->source = $source;
+               $notice->uri = $uri;
                
                $id = $notice->insert();
 
@@ -98,15 +97,14 @@ class Notice extends DB_DataObject
                        return _('Problem saving notice.');
                }
 
-               $orig = clone($notice);
-               if ($uri) {
-                       $notice->uri = $uri;
-               } else {
+               # Update the URI after the notice is in the database
+               if (!$uri) {
+                       $orig = clone($notice);
                        $notice->uri = common_notice_uri($notice);
-               }
 
-               if (!$notice->update($orig)) {
-                       return _('Problem saving notice.');
+                       if (!$notice->update($orig)) {
+                               return _('Problem saving notice.');
+                       }
                }
 
                # XXX: do we need to change this for remote users?