Fixed incorrect build ID not letting extension run (#15)

This commit is contained in:
David 2021-03-16 10:55:22 +13:00 committed by GitHub
parent 8685b1bf1d
commit 68aecf5816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,4 @@
use crate::bindings::{ZEND_BUILD_TS, ZEND_MODULE_API_NO}; use crate::bindings::{ZEND_BUILD_TS, ZEND_MODULE_API_NO, ZEND_BUILD_DEBUG, ZEND_BUILD_SYSTEM, ZEND_BUILD_EXTRA};
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
/// Takes a Rust string object, converts it into a C string /// Takes a Rust string object, converts it into a C string
@ -38,9 +38,15 @@ pub(crate) fn build_id() -> String {
// UNSAFE: reading a constant which has been translated from C, only reading and not // UNSAFE: reading a constant which has been translated from C, only reading and not
// modifying. // modifying.
let zend_build_ts = unsafe { CStr::from_ptr(ZEND_BUILD_TS.as_ptr() as *const i8) }; let zend_build_ts = unsafe { CStr::from_ptr(ZEND_BUILD_TS.as_ptr() as *const i8) };
let zend_build_debug = unsafe { CStr::from_ptr(ZEND_BUILD_DEBUG.as_ptr() as *const i8) };
let zend_build_system = unsafe { CStr::from_ptr(ZEND_BUILD_SYSTEM.as_ptr() as *const i8) };
let zend_build_extra = unsafe { CStr::from_ptr(ZEND_BUILD_EXTRA.as_ptr() as *const i8) };
format!( format!(
"API{}{}", "API{}{}{}{}{}",
ZEND_MODULE_API_NO, ZEND_MODULE_API_NO,
zend_build_ts.to_str().unwrap() zend_build_ts.to_str().unwrap(),
zend_build_debug.to_str().unwrap(),
zend_build_system.to_str().unwrap(),
zend_build_extra.to_str().unwrap()
) )
} }

View File

@ -1,3 +1,9 @@
#include "php.h" #include "php.h"
#include "ext/standard/info.h" #include "ext/standard/info.h"
#include "zend_extensions.h" #include "zend_exceptions.h"
// Need to define these as empty strings to ensure that
// bindgen generates them.
#define ZEND_BUILD_DEBUG ""
#define ZEND_BUILD_SYSTEM ""
#define ZEND_BUILD_EXTRA ""