diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-11-09 16:47:59 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-11-10 16:43:48 +0100 |
commit | 2c17d0b031b4081870d9ff86145e097ee257efb8 (patch) | |
tree | 6c6c6092a986cd73b5a4aebfc04b65a857e75faa /Zotlabs | |
parent | 57e69372d35b060dc29be2ff5527fc0ef19430e0 (diff) | |
download | volse-hubzilla-2c17d0b031b4081870d9ff86145e097ee257efb8.tar.gz volse-hubzilla-2c17d0b031b4081870d9ff86145e097ee257efb8.tar.bz2 volse-hubzilla-2c17d0b031b4081870d9ff86145e097ee257efb8.zip |
Module\Item: Make $item_id an object property.
This also allows us to deduplicate initialization and validation.
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Module/Item.php | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index fba16fbe1..a3943b3ad 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -40,9 +40,16 @@ require_once('include/conversation.php'); */ class Item extends Controller { + private string $item_id; function init() { + $this->item_id = argv(1); + + if (!$this->item_id) { + http_status_exit(404, 'Not found'); + } + if (Libzot::is_zot_request()) { $this->init_zot_request(); } @@ -51,7 +58,6 @@ class Item extends Controller { $this->init_as_request(); } - if (argc() > 1 && argv(1) !== 'drop') { $x = q("select uid, item_wall, llink, mid, uuid from item where mid = '%s' or mid = '%s' or uuid = '%s'", dbesc(z_root() . '/item/' . argv(1)), @@ -1452,11 +1458,6 @@ class Item extends Controller { private function init_zot_request() { - $item_id = argv(1); - - if (!$item_id) - http_status_exit(404, 'Not found'); - $portable_id = EMPTY_STR; $item_normal_extra = sprintf(" and not verb in ('Follow', 'Ignore', '%s', '%s') ", @@ -1471,7 +1472,7 @@ class Item extends Controller { // do we have the item (at all)? $r = q("select parent_mid from item where uuid = '%s' $item_normal limit 1", - dbesc($item_id) + dbesc($this->item_id) ); if (!$r) { @@ -1560,7 +1561,7 @@ class Item extends Controller { dbesc($portable_id) ); if (!$c) { - ThreadListener::store(z_root() . '/item/' . $item_id, $portable_id); + ThreadListener::store(z_root() . '/item/' . $this->item_id, $portable_id); } } @@ -1569,10 +1570,6 @@ class Item extends Controller { private function init_as_request() { - $item_id = argv(1); - if (!$item_id) - http_status_exit(404, 'Not found'); - $portable_id = EMPTY_STR; $item_normal_extra = sprintf(" and not verb in ('Follow', 'Ignore', '%s', '%s') ", @@ -1588,7 +1585,7 @@ class Item extends Controller { // add preferential bias to item owners (item_wall = 1) $r = q("select * from item where uuid = '%s' $item_normal order by item_wall desc limit 1", - dbesc($item_id) + dbesc($this->item_id) ); if (!$r) { @@ -1637,7 +1634,7 @@ class Item extends Controller { ); if ($t) { $i = q("select id as item_id from item where uuid = '%s' and id = %d $item_normal limit 1", - dbesc($item_id), + dbesc($this->item_id), intval($t[0]['iid']) ); } @@ -1672,7 +1669,7 @@ class Item extends Controller { dbesc($portable_id) ); if (!$c) { - ThreadListener::store(z_root() . '/item/' . $item_id, $portable_id); + ThreadListener::store(z_root() . '/item/' . $this->item_id, $portable_id); } } |