Fix crash on requesting all events if dbus logging enabled

afterLogEntriesGetManagedObjects prepares members array (all the
LogEntry objects) to be used in response to the /EventLog/Entries
requests. It calls the fillEventLogLogEntryFromPropertyMap for every
event passing the dbus properties map and json object, expecting
the function to translate the properties map to JSON. It stores all
the json objects in an array. It uses .emplace_back on the array
to create an empty instance of JSON object which it immediately
passes to be filled.
If something fails in fillEventLogLogEntryFromPropertyMap (like DBus
property map is malformed), it fires an internal error and return
immediately without filling any fields in JSON object.
As a result, in case of earlier return from the function, the array will
have objects with no data. After collecting all the objects, it reorders
the elements by Id, however as some of them have no Id fields populated,
accessing to non-existent fields causes service to crash.

Testing:
Before the command [1] the process core dumped.

After, the same command [1] works [2].
Requesting individual entries keeps working [3].

[1] Command to fetch all EventLog Entries:
```
curl -ks -H "Content-Type: application/json" -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
```

[2] Result from the server after fixing
```
root@bmc:~# curl -ks -H "Content-Type: application/json" -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
{
  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
  "@odata.type": "#LogEntryCollection.LogEntryCollection",
  "Description": "Collection of System Event Log Entries",
  "Name": "System Event Log Entries",
  "error": {
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "#Message.v1_1_1.Message",
        "Message": "The request failed due to an internal service error.  The service is still operational.",
        "MessageArgs": [],
        "MessageId": "Base.1.19.InternalError",
        "MessageSeverity": "Critical",
        "Resolution": "Resubmit the request.  If the problem persists, consider resetting the service."
      }
    ],
    "code": "Base.1.19.InternalError",
    "message": "The request failed due to an internal service error.  The service is still operational."
  }
}
```

[3] Fetching a single entry correct and failing
```
root@bmc:~# curl -ks -H "Content-Type: application/json" -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "#Message.v1_1_1.Message",
        "Message": "The request failed due to an internal service error.  The service is still operational.",
        "MessageArgs": [],
        "MessageId": "Base.1.19.InternalError",
        "MessageSeverity": "Critical",
        "Resolution": "Resubmit the request.  If the problem persists, consider resetting the service."
      }
    ],
    "code": "Base.1.19.InternalError",
    "message": "The request failed due to an internal service error.  The service is still operational."
  }
}

root@bmc:~# curl -ks -H "Content-Type: application/json" -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/2
{
  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2",
  "@odata.type": "#LogEntry.v1_9_0.LogEntry",
  "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2/attachment",
  "Created": "2025-04-02T09:54:37.777+00:00",
  "EntryType": "Event",
  "Id": "2",
  "Message": "Sensor 'BIC_JI_SENSOR_MB_RETIMER_TEMP_C' reading of 10.2 (xyz.openbmc_project.Sensor.Value.Unit.DegreesC) is below the 15.5 lower critical threshold.",
  "MessageArgs": [
    "BIC_JI_SENSOR_MB_RETIMER_TEMP_C",
    "10.2",
    "xyz.openbmc_project.Sensor.Value.Unit.DegreesC",
    "15.5"
  ],
  "MessageId": "SensorEvent.1.0.ReadingBelowLowerCriticalThreshold",
  "Modified": "2025-04-02T09:54:37.777+00:00",
  "Name": "System Event Log Entry",
  "Resolution": "Check the condition of the resources listed in RelatedItem.",
  "Resolved": false,
  "Severity": "Critical"
}
```

Change-Id: I231b2266ccee27e83363cd1363c130d3fe8f1ed3
Signed-off-by: Igor Kanyuka <ifelmail@gmail.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index fd76da5..cde992b 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1426,7 +1426,7 @@
     return LogParseError::success;
 }
 
-inline void fillEventLogLogEntryFromPropertyMap(
+inline bool fillEventLogLogEntryFromPropertyMap(
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
     const dbus::utility::DBusPropertiesMap& resp,
     nlohmann::json& objectToFillOut)
@@ -1437,7 +1437,7 @@
     if (!optEntry.has_value())
     {
         messages::internalError(asyncResp->res);
-        return;
+        return false;
     }
     DbusEventLogEntry entry = optEntry.value();
 
@@ -1472,6 +1472,7 @@
             "/redfish/v1/Systems/{}/LogServices/EventLog/Entries/{}/attachment",
             BMCWEB_REDFISH_SYSTEM_URI_NAME, std::to_string(entry.Id));
     }
+    return true;
 }
 
 inline void afterLogEntriesGetManagedObjects(
@@ -1507,14 +1508,15 @@
                                             propertyMap.second);
             }
         }
-        fillEventLogLogEntryFromPropertyMap(asyncResp, propsFlattened,
-                                            entriesArray.emplace_back());
+        bool success = fillEventLogLogEntryFromPropertyMap(
+            asyncResp, propsFlattened, entriesArray.emplace_back());
+        if (!success)
+        {
+            return;
+        }
     }
 
-    std::ranges::sort(entriesArray, [](const nlohmann::json& left,
-                                       const nlohmann::json& right) {
-        return (left["Id"] <= right["Id"]);
-    });
+    redfish::json_util::sortJsonArrayByKey(entriesArray, "Id");
     asyncResp->res.jsonValue["Members@odata.count"] = entriesArray.size();
     asyncResp->res.jsonValue["Members"] = std::move(entriesArray);
 }