# هل تأثر تحويل الحقول المخصصة بالتحديث الأخير؟

**URL:** <https://meta.discourse.org/t/custom-field-casting-affected-by-recent-update/122746>\
**Category:** Development\
**Created:** [11 يوليو 2019، 11:34م UTC](https://meta.discourse.org/t/custom-field-casting-affected-by-recent-update/122746 "2019-07-11T23:34:41Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [11 يوليو 2019، 11:34م UTC](https://meta.discourse.org/t/custom-field-casting-affected-by-recent-update/122746/1 "2019-07-11T23:34:42Z")

</div>

تم الإبلاغ عن أخطاء متعددة في [إضافة الأحداث](https://meta.discourse.org/t/events-plugin-calendar) خلال اليومين الماضيين، وتبدو جميعها مرتبطة بمشاكل تحويل الأنواع في الحقول المخصصة. لم يتم تحديث إضافة الأحداث بشكل جوهري منذ بضعة أشهر.

> [@Events Plugin calendar](https://meta.discourse.org/t/events-plugin-calendar/69776/482?u=angus):
>
> Is the bellow error related to this plugin? (also posted [here](https://meta.discourse.org/t/topic-in-a-category-make-unreachable-the-category-and-user-activity-and-the-topic-itself/122644)) a user created a topic by copy pasting some content from a facebook page; this has crashed the topic iteslf, the category and his activities page. (the rest of the topics and categories of the site remained accessible) I managed to destroy the topic from the console and everything went back to normal for the user and category. Is this error related to the mentioned plugin [“discourse-events”](https://meta.discourse.org/t/events-plugin-calendar/69776)? here follows the errors: info: NoMet…

في ملف plugin.rb، يتم تحويل `event_start` إلى عدد صحيح:

```plaintext
Topic.register_custom_field_type('event_start', :integer)

```

يتم إلقاء الخطأ هنا:

```plaintext
def has_event?
  self.custom_fields['event_start']&.nonzero?
end

```

يتبع الخطأ نفسه هذا التنسيق:

```plaintext
NoMethodError (undefined method `nonzero?' for [1563127206, 1563127206]:Array)

```

حسب فهمي لـ `register_custom_field_type`، يجب أن يضمن أن الحقل المخصص يُرجع دائمًا النوع المحدد (ربما أنا أساءت فهمه).

بالنظر إلى مكون `has_custom_fields.rb`، كانت هناك بعض التغييرات خلال الأسبوع الماضي قد تكون أثرت على هذا، خاصةً:

> <https://github.com/discourse/discourse/commit/72bac61c90044407f7a2029b15f6ac043a8bccf0#diff-712e064741bd664591e6392a52eb409e>

@eviltrout هل لديك أي أفكار حول هذا؟

---

_[View the full topic](https://meta.discourse.org/t/custom-field-casting-affected-by-recent-update/122746)._
