-
Notifications
You must be signed in to change notification settings - Fork 6
Rel1 39 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Rel1 39 #11
Changes from all commits
750ee37
8b8be88
dadf595
04071f8
9caf3fe
7c1856b
3740583
c4f259a
2523e74
10d40bd
35b1536
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,22 @@ | |
|
|
||
| namespace MediaWiki\Extension\SemanticWikibase\EntryPoints; | ||
|
|
||
| use MediaWiki\Revision\RenderedRevision; | ||
| use MediaWiki\User\UserIdentity; | ||
| use CommentStoreComment; | ||
| use Status; | ||
| use MediaWiki\MediaWikiServices; | ||
| use MediaWiki\TitleFactory; | ||
| use MediaWiki\Extension\SemanticWikibase\SemanticWikibase; | ||
| use SMW\Services\ServicesFactory as ApplicationFactory; | ||
| use SMW\PropertyRegistry; | ||
| use SMW\SemanticData; | ||
| use SMW\DIWikiPage; | ||
| use SMW\StoreFactory; | ||
| use SMW\Store; | ||
|
|
||
| use Parser; | ||
|
|
||
| class HookHandlers { | ||
|
|
||
| public static function onExtensionRegistration(): void { | ||
|
|
@@ -17,18 +28,52 @@ public static function onExtensionRegistration(): void { | |
| $smwgNamespacesWithSemanticLinks[WB_NS_PROPERTY] = true; | ||
| } | ||
|
|
||
| public static function onParserFirstCallInit( Parser $parser ) { | ||
| # getInstance() will call initProperties() which aktivates existing hook onSmwInitProperties() | ||
| wfDebug( __METHOD__ . "SWB: onParserFirstCallInit" ); | ||
| PropertyRegistry::getInstance(); | ||
| } | ||
|
|
||
| public static function onSmwInitProperties( PropertyRegistry $propertyRegistry ): void { | ||
| SemanticWikibase::getGlobalInstance()->registerProperties( $propertyRegistry ); | ||
| wfDebug( __METHOD__ . "SWB: onSmwInitProperties..." ); | ||
| SemanticWikibase::getGlobalInstance()->registerProperties( $propertyRegistry ); | ||
| } | ||
|
|
||
| public static function onSmwAddCustomFixedPropertyTables( array &$customFixedProperties, array &$fixedPropertyTablePrefix ): void { | ||
| wfDebug( __METHOD__ . "SWB: onSmwAddCustomFixedPropertyTables" ); | ||
| SemanticWikibase::getGlobalInstance()->getFixedProperties() | ||
| ->registerFixedTables( $customFixedProperties, $fixedPropertyTablePrefix ); | ||
| } | ||
|
|
||
| public static function onSmwUpdateDataBefore( Store $store, SemanticData $semanticData ): void { | ||
| wfDebug( __METHOD__ . "SWB: onSmwUpdateDataBefore" ); | ||
| SemanticWikibase::getGlobalInstance()->getSemanticDataUpdate() | ||
| ->run( $semanticData ); | ||
|
|
||
| } | ||
|
|
||
| public static function onPageSaveComplete( WikiPage $wikiPage, MediaWiki\User\UserIdentity $user, string $summary, int $flags, MediaWiki\Revision\RevisionRecord $revisionRecord, MediaWiki\Storage\EditResult $editResult ) { | ||
| wfDebug( __METHOD__ . "SWB: onPageSaveComplete" ); | ||
| // Access the semantic data of the page via the Semantic MediaWiki API | ||
| $semanticData = \SMW\MediaWiki\Hooks\ParserHooks::getSemanticDataForPage($wikiPage); | ||
|
|
||
| onSmwUpdateDataBefore(null, $semanticData); | ||
| } | ||
|
Comment on lines
+55
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find the HookHandlers.php file and check its imports and structure
find . -name "HookHandlers.php" -type fRepository: ProfessionalWiki/SemanticWikibase Length of output: 111 🏁 Script executed: # Check imports and full content of HookHandlers.php
head -30 "src/EntryPoints/HookHandlers.php"Repository: ProfessionalWiki/SemanticWikibase Length of output: 821 🏁 Script executed: # Search for onSmwUpdateDataBefore method definition in the file
rg "onSmwUpdateDataBefore" "src/EntryPoints/HookHandlers.php" -A 5 -B 2Repository: ProfessionalWiki/SemanticWikibase Length of output: 755 🏁 Script executed: # Search for WikiPage import
rg "use.*WikiPage" "src/EntryPoints/HookHandlers.php"Repository: ProfessionalWiki/SemanticWikibase Length of output: 96 🏁 Script executed: # Check if ParserHooks class exists and search for getSemanticDataForPage
find . -name "*.php" -type f | xargs rg "ParserHooks" | head -20Repository: ProfessionalWiki/SemanticWikibase Length of output: 204 🌐 Web query:
💡 Result:
If you meant an internal PHP API (e.g., from an extension / parser hook callback) to get semantic data for the current parse, SMW’s documented pattern is to create SMW parser functions (“parser hooks”) themselves are documented here (e.g., Critical:
🐛 Proposed fix+use WikiPage;
-public static function onPageSaveComplete( WikiPage $wikiPage, MediaWiki\User\UserIdentity $user, string $summary, int $flags, MediaWiki\Revision\RevisionRecord $revisionRecord, MediaWiki\Storage\EditResult $editResult ) {
+public static function onPageSaveComplete( WikiPage $wikiPage, UserIdentity $user, string $summary, int $flags, \MediaWiki\Revision\RevisionRecord $revisionRecord, \MediaWiki\Storage\EditResult $editResult ): void {
wfDebug( __METHOD__ . "SWB: onPageSaveComplete" );
- // Access the semantic data of the page via the Semantic MediaWiki API
- $semanticData = \SMW\MediaWiki\Hooks\ParserHooks::getSemanticDataForPage($wikiPage);
-
- onSmwUpdateDataBefore(null, $semanticData);
+ $semanticData = StoreFactory::getStore()->getSemanticData( DIWikiPage::newFromTitle( $wikiPage->getTitle() ) );
+ self::onSmwUpdateDataBefore( StoreFactory::getStore(), $semanticData );
}🧰 Tools🪛 PHPMD (2.15.0)[warning] 55-55: Avoid unused parameters such as '$user'. (undefined) (UnusedFormalParameter) [warning] 55-55: Avoid unused parameters such as '$summary'. (undefined) (UnusedFormalParameter) [warning] 55-55: Avoid unused parameters such as '$flags'. (undefined) (UnusedFormalParameter) [warning] 55-55: Avoid unused parameters such as '$revisionRecord'. (undefined) (UnusedFormalParameter) [warning] 55-55: Avoid unused parameters such as '$editResult'. (undefined) (UnusedFormalParameter) 🤖 Prompt for AI Agents |
||
|
|
||
| public static function onMultiContentSave( RenderedRevision $renderedRevision, UserIdentity $user, CommentStoreComment $summary, $flags, Status $hookStatus ) { | ||
| wfDebug( __METHOD__ . "SWB: onMultiContentSave" ); | ||
| $revision = $renderedRevision->getRevision(); | ||
|
|
||
| $titleFactory = MediaWikiServices::getInstance()->getTitleFactory(); | ||
| $title = $titleFactory->newFromLinkTarget($revision->getPageAsLinkTarget()); | ||
| wfDebug( __METHOD__ . "SWB: onMultiContentSave...title:".$title ); | ||
| $subject = DIWikiPage::newFromTitle( $title ); | ||
| #$new_content = $revision->getContent(SlotRecord::MAIN, RevisionRecord::RAW)->getNativeData(); | ||
| $semanticData = StoreFactory::getStore()->getSemanticData( DIWikiPage::newFromTitle( $title ) ); | ||
| wfDebug( __METHOD__ . "SWB: onMultiContentSave: ".json_encode($semanticData) ); | ||
| SemanticWikibase::getGlobalInstance()->getSemanticDataUpdate()->run( $semanticData ); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,28 +8,34 @@ | |||||||||||||||||||||||||
| use SMW\DIWikiPage; | ||||||||||||||||||||||||||
| use SMW\SemanticData; | ||||||||||||||||||||||||||
| use SMWDataItem; | ||||||||||||||||||||||||||
| use SMW\Subobject; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| class SemanticEntity { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private array $dataItemsPerProperty = []; | ||||||||||||||||||||||||||
| private array $subObjectsPerProperty=[]; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public function addPropertyValue( string $propertyId, SMWDataItem $dataItem ) { | ||||||||||||||||||||||||||
| $this->dataItemsPerProperty[$propertyId][] = $dataItem; | ||||||||||||||||||||||||||
| public function addPropertyValue( string $NumericPropertyId, SMWDataItem $dataItem ) { | ||||||||||||||||||||||||||
| $this->dataItemsPerProperty[$NumericPropertyId][] = $dataItem; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public function addSubobject( string $NumericPropertyId, SubObject $subobject ){ | ||||||||||||||||||||||||||
| $this->subObjectsPerProperty[$NumericPropertyId][] = $subobject; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+22
to
24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Case mismatch in type hint: The import at line 11 is 🐛 Proposed fix-public function addSubobject( string $NumericPropertyId, SubObject $subobject ){
+public function addSubobject( string $NumericPropertyId, Subobject $subobject ): void {
$this->subObjectsPerProperty[$NumericPropertyId][] = $subobject;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * @param string $propertyId | ||||||||||||||||||||||||||
| * @param string $NumericPropertyId | ||||||||||||||||||||||||||
| * @return SMWDataItem[] | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| public function getDataItemsForProperty( string $propertyId ): array { | ||||||||||||||||||||||||||
| return $this->dataItemsPerProperty[$propertyId] ?? []; | ||||||||||||||||||||||||||
| public function getDataItemsForProperty( string $NumericPropertyId ): array { | ||||||||||||||||||||||||||
| return $this->dataItemsPerProperty[$NumericPropertyId] ?? []; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public function toSemanticData( DIWikiPage $subject ): SemanticData { | ||||||||||||||||||||||||||
| $semanticData = new SemanticData( $subject ); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ( $this->dataItemsPerProperty as $propertyId => $dataItems ) { | ||||||||||||||||||||||||||
| $property = new DIProperty( $propertyId ); | ||||||||||||||||||||||||||
| foreach ( $this->dataItemsPerProperty as $NumericPropertyId => $dataItems ) { | ||||||||||||||||||||||||||
| $property = new DIProperty( $NumericPropertyId ); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ( $dataItems as $dataItem ) { | ||||||||||||||||||||||||||
| $semanticData->addPropertyObjectValue( | ||||||||||||||||||||||||||
|
|
@@ -39,6 +45,14 @@ public function toSemanticData( DIWikiPage $subject ): SemanticData { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ( $this->subObjectsPerProperty as $NumericPropertyId => $subobjects ) { | ||||||||||||||||||||||||||
| $property = new DIProperty( $NumericPropertyId ); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ( $subobjects as $subobject ) { | ||||||||||||||||||||||||||
| $semanticData->addSubobject($subobject); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+48
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused variable The 🐛 Proposed fix - remove unused variable foreach ( $this->subObjectsPerProperty as $NumericPropertyId => $subobjects ) {
- $property = new DIProperty( $NumericPropertyId );
-
foreach ( $subobjects as $subobject ) {
$semanticData->addSubobject($subobject);
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return $semanticData; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -52,9 +66,9 @@ public function functionalMerge( self $entity ): self { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public function add( self $entity ): void { | ||||||||||||||||||||||||||
| foreach ( $entity->dataItemsPerProperty as $propertyId => $dataItems ) { | ||||||||||||||||||||||||||
| foreach ( $entity->dataItemsPerProperty as $NumericPropertyId => $dataItems ) { | ||||||||||||||||||||||||||
| foreach ( $dataItems as $dataItem ) { | ||||||||||||||||||||||||||
| $this->addPropertyValue( $propertyId, $dataItem ); | ||||||||||||||||||||||||||
| $this->addPropertyValue( $NumericPropertyId, $dataItem ); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
68
to
74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Subobjects are not merged in the The 🐛 Proposed fix public function add( self $entity ): void {
foreach ( $entity->dataItemsPerProperty as $NumericPropertyId => $dataItems ) {
foreach ( $dataItems as $dataItem ) {
$this->addPropertyValue( $NumericPropertyId, $dataItem );
}
}
+ foreach ( $entity->subObjectsPerProperty as $NumericPropertyId => $subobjects ) {
+ foreach ( $subobjects as $subobject ) {
+ $this->addSubobject( $NumericPropertyId, $subobject );
+ }
+ }
}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,14 +19,33 @@ | |
| use Wikibase\DataModel\Entity\EntityId; | ||
| use Wikibase\DataModel\Entity\EntityIdValue; | ||
| use Wikibase\DataModel\Entity\ItemId; | ||
| use Wikibase\DataModel\Entity\PropertyId; | ||
| use Wikibase\DataModel\Entity\NumericPropertyId; | ||
| use Wikibase\EDTF\Services\TimeValueBuilder; | ||
| use Wikibase\EDTF\EdtfValue; | ||
| use MediaWiki\Logger\LoggerFactory; | ||
| use EDTF\EdtfFactory; | ||
| use EDTF\Model\ExtDate; | ||
| use EDTF\Model\ExtDateTime; | ||
| use EDTF\Model\Interval; | ||
|
|
||
| class DataValueTranslator { | ||
|
|
||
| public function translate( TypedDataValue $typedValue ): SMWDataItem { | ||
|
|
||
|
|
||
| $value = $typedValue->getValue(); | ||
|
|
||
| $propertyType = $typedValue->getPropertyType(); | ||
| if( $value != null) { | ||
| wfDebug( 'swb: translate: '.get_class( $value ).' ptype: '.$propertyType ); | ||
| } | ||
|
|
||
| if ( $value instanceof StringValue ) { | ||
| wfDebug( 'swb: translate: '. $typedValue->getValue()->getValue() ); | ||
|
Comment on lines
+39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid logging raw translated values. Lines 39/43/129 log raw payload content and humanized values. This can leak sensitive imported data and create noisy debug logs. Also applies to: 121-130 🤖 Prompt for AI Agents |
||
| if( $propertyType == 'edtf') { | ||
| return $this->translateEDTF("".$value->getValue()); | ||
| }else if ($propertyType == 'localMedia') { | ||
| return $this->translateLocalMedia("".$value->getValue()); | ||
| } | ||
| return $this->translateStringValue( $typedValue ); | ||
| } | ||
| if ( $value instanceof BooleanValue ) { | ||
|
|
@@ -44,10 +63,13 @@ public function translate( TypedDataValue $typedValue ): SMWDataItem { | |
| if ( $value instanceof GlobeCoordinateValue ) { | ||
| return $this->translateGlobeCoordinateValue( $value ); | ||
| } | ||
|
|
||
| if ( $value instanceof TimeValue ) { | ||
| wfDebug( 'swb: translate time: '. $$value.toString() ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n src/Translation/DataValueTranslator.php | sed -n '60,80p'Repository: ProfessionalWiki/SemanticWikibase Length of output: 925 🏁 Script executed: # Check the full context around line 68
head -n 80 src/Translation/DataValueTranslator.php | tail -n 25Repository: ProfessionalWiki/SemanticWikibase Length of output: 880 🏁 Script executed: # Search for TimeValue class definition to understand available methods
rg -n 'class TimeValue|interface TimeValue' --type phpRepository: ProfessionalWiki/SemanticWikibase Length of output: 59 🏁 Script executed: # Verify the syntax - check if $$ pattern exists in the file
rg -n '\$\$' src/Translation/DataValueTranslator.phpRepository: ProfessionalWiki/SemanticWikibase Length of output: 140 🏁 Script executed: # Find TimeValue class definition
rg -n 'class TimeValue|interface TimeValue' -A 10 --type phpRepository: ProfessionalWiki/SemanticWikibase Length of output: 59 🏁 Script executed: # Check methods available on TimeValue
rg -n 'public function' -A 2 --type php | grep -A 2 -B 2 'getTime\|toString'Repository: ProfessionalWiki/SemanticWikibase Length of output: 59 🏁 Script executed: # Look for translateTimeValue method implementation
rg -n 'translateTimeValue' src/Translation/DataValueTranslator.php -A 15Repository: ProfessionalWiki/SemanticWikibase Length of output: 1356 🏁 Script executed: # Check the null return type issue mentioned in scratchpad (Line 140)
head -n 145 src/Translation/DataValueTranslator.php | tail -n 20Repository: ProfessionalWiki/SemanticWikibase Length of output: 762 🏁 Script executed: # Find the method containing line 140
sed -n '100,150p' src/Translation/DataValueTranslator.php | cat -nRepository: ProfessionalWiki/SemanticWikibase Length of output: 2022 🏁 Script executed: # Look for method signatures with return types in that range
rg -n 'private function|public function' src/Translation/DataValueTranslator.php | grep -E '(1[0-3][0-9]|14[0-5])'Repository: ProfessionalWiki/SemanticWikibase Length of output: 296 🏁 Script executed: # Get more context - find what method contains line 140
head -n 145 src/Translation/DataValueTranslator.php | tail -n 50Repository: ProfessionalWiki/SemanticWikibase Length of output: 1708 🏁 Script executed: # Get the complete translateEDTF method
sed -n '120,160p' src/Translation/DataValueTranslator.php | cat -nRepository: ProfessionalWiki/SemanticWikibase Length of output: 1730 Fix invalid TimeValue debug expression on Line 68.
Proposed fix- if ( $value instanceof TimeValue ) {
- wfDebug( 'swb: translate time: '. $$value.toString() );
- return $this->translateTimeValue( $value );
- }
+ if ( $value instanceof TimeValue ) {
+ wfDebug( 'swb: translate time: ' . $value->getTime() );
+ return $this->translateTimeValue( $value );
+ }🤖 Prompt for AI Agents |
||
| return $this->translateTimeValue( $value ); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| throw new \RuntimeException( 'Support for DataValue type "' . get_class( $value ) . '" not implemented' ); | ||
| } | ||
|
|
||
|
|
@@ -66,6 +88,12 @@ private function translateGlobeCoordinateValue( GlobeCoordinateValue $globeValue | |
| ); | ||
| } | ||
|
|
||
| private function translateLocalMedia( String $imagePage): SMWDataItem { | ||
| return new DIWikiPage( | ||
| $imagePage, | ||
| NS_FILE | ||
| ); | ||
| } | ||
| private function translateEntityIdValue( EntityIdValue $idValue ): SMWDataItem { | ||
| return new DIWikiPage( | ||
| $idValue->getEntityId()->getSerialization(), | ||
|
|
@@ -78,7 +106,7 @@ private function entityIdToNamespaceId( EntityId $idValue ): int { | |
| return WB_NS_ITEM; | ||
| } | ||
|
|
||
| if ( $idValue instanceof PropertyId ) { | ||
| if ( $idValue instanceof NumericPropertyId ) { | ||
| return WB_NS_PROPERTY; | ||
| } | ||
|
|
||
|
|
@@ -89,6 +117,59 @@ public function translateDecimalValue( DecimalValue $value ): SMWDataItem { | |
| return new \SMWDINumber( $value->getValueFloat() ); | ||
| } | ||
|
|
||
| private function translateEDTF( String $value ): \SMWDITime { | ||
| wfDebug( 'swb: translate edtf' ); | ||
| $tvb = new TimeValueBuilder( EdtfFactory::newParser() ); | ||
| $tvArr = $tvb->edtfToTimeValues( $value ); | ||
| $parser = \EDTF\EdtfFactory::newParser(); | ||
| $parsingResult = $parser->parse($value); | ||
| wfDebug($parsingResult->isValid()); // true | ||
| $edtfValue = $parsingResult->getEdtfValue(); // \EDTF\EdtfValue | ||
| $humanizer = \EDTF\EdtfFactory::newHumanizerForLanguage( 'en' ); | ||
| wfDebug($humanizer->humanize($edtfValue)); // string | ||
| wfDebug(get_class($edtfValue)); // string | ||
| $result = null; | ||
|
|
||
| if ( $edtfValue instanceof Interval ) { | ||
| if($edtfValue->hasStartDate()){ | ||
| $edtfValue = $edtfValue->getStartDate(); | ||
| } else if ($edtfValue->hasEndDate()){ | ||
| $edtfValue = $edtfValue->getEndDate(); | ||
| } else { | ||
| wfDebug('ERROR: unable to translate empty edtf interval to smw date'); | ||
| return null; | ||
| } | ||
|
Comment on lines
+120
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, verify the function signature and null returns as suggested
cd src/Translation && rg -n -C3 'private function translateEDTF\(|return null;' DataValueTranslator.phpRepository: ProfessionalWiki/SemanticWikibase Length of output: 553 🏁 Script executed: #!/bin/bash
# Also get the complete function to see all return statements and context
rg -n -A30 'private function translateEDTF' src/Translation/DataValueTranslator.php | head -60Repository: ProfessionalWiki/SemanticWikibase Length of output: 1291 🏁 Script executed: #!/bin/bash
# Check if there are any other return statements in this function
rg -n 'return' src/Translation/DataValueTranslator.php | grep -A5 -B5 'translateEDTF'Repository: ProfessionalWiki/SemanticWikibase Length of output: 430 🏁 Script executed: #!/bin/bash
# Get the complete function from translateEDTF
rg -n -A100 'private function translateEDTF' src/Translation/DataValueTranslator.php | head -120Repository: ProfessionalWiki/SemanticWikibase Length of output: 2560 Replace
Suggested fix } else {
wfDebug('ERROR: unable to translate empty edtf interval to smw date');
- return null;
+ return new \SMWDITime( SMWDITime::CM_GREGORIAN, 1970 );
}🧰 Tools🪛 PHPMD (2.15.0)[warning] 123-123: Avoid unused local variables such as '$tvArr'. (undefined) (UnusedLocalVariable) 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| if( $edtfValue instanceof ExtDate ) { | ||
| $result = new \SMWDITime( | ||
| SMWDITime::CM_GREGORIAN, | ||
| $edtfValue->getYear(), | ||
| $edtfValue->getMonth(), | ||
| $edtfValue->getDay() | ||
| ); | ||
|
|
||
| } else if ( $edtfValue instanceof ExtDateTime ) { | ||
| $result = new \SMWDITime( | ||
| SMWDITime::CM_GREGORIAN, | ||
| $edtfValue->getYear(), | ||
| $edtfValue->getMonth(), | ||
| $edtfValue->getDay(), | ||
| $edtfValue->getHour(), | ||
| $edtfValue->getMinute(), | ||
| $edtfValue->getSecond() | ||
| ); | ||
| } else { | ||
| $result = new \SMWDITime( | ||
| SMWDITime::CM_GREGORIAN, | ||
| 1970 | ||
| ); | ||
|
|
||
| } | ||
|
|
||
| return $result; | ||
| } | ||
|
|
||
| private function translateTimeValue( TimeValue $value ): \SMWDITime { | ||
| $components = ( new TimeValueParser() )->parse( $value->getTime() ); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package metadata changes may cause issues if merged upstream.
The package
nameandhomepagehave been changed to point to a personal fork, but thesupportURLs (lines 32-34) still reference the originalProfessionalWiki/SemanticWikibaserepository. This creates an inconsistency.If this PR is intended to be merged back to the upstream repository, consider reverting these changes to maintain the original package identity. If this is a permanent fork, update the
supportURLs as well for consistency.Also applies to: 15-15
🤖 Prompt for AI Agents