dataStore->getDataDirectory() . DIRECTORY_SEPARATOR . $this->getFileName(); } /** * Get file statistics for the data file. * * @return array|false File stat array with 'mtime' and 'size', or false if file doesn't exist. * * @phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged */ protected function getFileStat() { $filePath = $this->getFilePath(); if ( ! file_exists( $filePath ) ) { return false; } return @stat( $filePath ); } /** * Invalidate OPcache for a file. * * This ensures we get the latest version of the file when it's been * modified by the Imunify agent. * * @param string $filePath The path to the file to invalidate. * * @return bool True if successful, false otherwise. */ protected function invalidateOpcache( $filePath ) { return opcache_invalidate( $filePath, true ); } /** * Load data from file with OPcache invalidation. * * @return mixed The data from the file, or null if not available. */ protected function loadDataFromFile() { if ( ! $this->dataStore->isDataFileAvailable( $this->getFileName() ) ) { return null; } // Invalidate OPcache to ensure we get the latest version. if ( function_exists( 'opcache_invalidate' ) ) { $filePath = $this->getFilePath(); $this->invalidateOpcache( $filePath ); } return $this->dataStore->load( $this->getFileName() ); } /** * Force reload data from file. * * Clears caches and reloads data from the source file. * * @return mixed The reloaded data. */ abstract public function forceReload(); }